Zelda Classic Coverage Report


Directory: src/
File: src/guys.cpp
Date: 2023-03-19 02:19:21
Exec Total Coverage
Lines: 8497 13222 64.3%
Functions: 323 425 76.0%
Branches: 6610 14524 45.5%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // guys.cc
6 //
7 // "Guys" code (and other related stuff) for zelda.cc
8 //
9 //--------------------------------------------------------
10
11 #include "precompiled.h" //always first
12
13 #include <string.h>
14 #include <stdio.h>
15 #include "base/zc_alleg.h"
16 #include "guys.h"
17
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 #include "zelda.h"
18 #include "base/zsys.h"
19 #include "maps.h"
20 #include "hero.h"
21 #include "subscr.h"
22 #include "ffscript.h"
23 #include "gamedata.h"
24 #include "defdata.h"
25 #include "zscriptversion.h"
26 #include "particles.h"
27 #include "base/zc_math.h"
28 #include "slopes.h"
29 extern particle_list particles;
30
31 extern FFScript FFCore;
32 extern word item_doscript[256];
33 extern refInfo itemScriptData[256];
34 extern int32_t item_stack[256][MAX_SCRIPT_REGISTERS];
35 extern ZModule zcm;
36 extern HeroClass Hero;
37 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
38 extern zinitdata zinit;
39
40 int32_t repaircharge=0;
41 bool adjustmagic=false;
42 bool learnslash=false;
43 int32_t wallm_load_clk=0;
44 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
45 int32_t vhead=0;
46 int32_t guycarryingitem=0;
47
48 char *guy_string[eMAXGUYS];
49
50 void never_return(int32_t index);
51 void playLevelMusic();
52
53 // If an enemy is this far out of the playing field, just remove it.
54 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
55 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
56 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
57 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
58
59 484017 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
60 {
61 484017 int32_t c = coord.getInt();
62
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 483750 times.
484017 if(nearest_half)
63 {
64
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483750 times.
483750 if (c < 0)
65 c -= val / 2;
66 483750 else c += (val/2);
67 483750 }
68 484017 c -= c % val;
69 484017 coord = c;
70 484017 }
71
72 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
73 {
74 return
75 (
76 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
77 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
78 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
79 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
80 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
81 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
82 );
83 }
84
85 namespace
86 {
87 int32_t trapConstantHorizontalID;
88 int32_t trapConstantVerticalID;
89 int32_t trapLOSHorizontalID;
90 int32_t trapLOSVerticalID;
91 int32_t trapLOS4WayID;
92
93 int32_t cornerTrapID;
94 int32_t centerTrapID;
95
96 int32_t rockID;
97 int32_t zoraID;
98 int32_t statueID;
99 }
100
101 94 void identifyCFEnemies()
102 {
103 94 trapConstantHorizontalID=-1;
104 94 trapConstantVerticalID=-1;
105 94 trapLOSHorizontalID=-1;
106 94 trapLOSVerticalID=-1;
107 94 trapLOS4WayID=-1;
108 94 cornerTrapID=-1;
109 94 centerTrapID=-1;
110 94 rockID=-1;
111 94 zoraID=-1;
112 94 statueID=-1;
113
114
2/2
✓ Branch 0 taken 48128 times.
✓ Branch 1 taken 94 times.
48222 for(int32_t i=0; i<eMAXGUYS; i++)
115 {
116
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 48035 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
48128 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
117 93 trapLOSHorizontalID=i;
118
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 48031 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
119 94 trapLOSVerticalID=i;
120
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
121 94 trapLOS4WayID=i;
122
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
123 94 trapConstantHorizontalID=i;
124
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
125 94 trapConstantVerticalID=i;
126
127
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
128 94 cornerTrapID=i;
129
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
130 94 centerTrapID=i;
131
132
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
133 94 rockID=i;
134
3/4
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 48034 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
135 94 zoraID=i;
136
137
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 48031 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 94 times.
48128 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
138 94 statueID=i;
139 48128 }
140 94 }
141
142 25 int32_t random_layer_enemy()
143 {
144 25 int32_t cnt=count_layer_enemies();
145
146
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
147 {
148 return eNONE;
149 }
150
151 25 int32_t ret=zc_oldrand()%cnt;
152 25 cnt=0;
153
154
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
155 {
156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
157 {
158 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
159
160
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
161 {
162
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
163 {
164
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
165 {
166 25 return layerscreen->enemy[j];
167 }
168
169 102 ++cnt;
170 102 }
171 102 }
172 }
173 }
174
175 return eNONE;
176 25 }
177
178 39 int32_t count_layer_enemies()
179 {
180 39 int32_t cnt=0;
181
182
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
183 {
184
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
185 {
186 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
187
188
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
189 {
190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
191 {
192 390 ++cnt;
193 390 }
194 390 }
195 39 }
196 234 }
197
198 39 return cnt;
199 }
200
201 113541 int32_t hero_on_wall()
202 {
203 113541 zfix lx = Hero.getX();
204 113541 zfix ly = Hero.getY();
205
206
207 //zprint2("hero_on_wall x is: %d\n", lx);
208 //zprint2("hero_on_wall y is: %d\n", ly);
209
210
4/4
✓ Branch 0 taken 106579 times.
✓ Branch 1 taken 6962 times.
✓ Branch 2 taken 2931 times.
✓ Branch 3 taken 103648 times.
113541 if(lx>=48 && lx<=192)
211 {
212
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 103523 times.
103648 if(ly==32) return up+1;
213
214
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 103421 times.
103523 if(ly==128) return down+1;
215 103421 }
216
217
4/4
✓ Branch 0 taken 105191 times.
✓ Branch 1 taken 8123 times.
✓ Branch 2 taken 9150 times.
✓ Branch 3 taken 96041 times.
113314 if(ly>=48 && ly<=112)
218 {
219
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 95938 times.
96041 if(lx==32) return left+1;
220
221
2/2
✓ Branch 0 taken 95891 times.
✓ Branch 1 taken 47 times.
95938 if(lx==208) return right+1;
222 95891 }
223
224 113164 return 0;
225 113541 }
226
227 655550 bool tooclose(int32_t x,int32_t y,int32_t d)
228 {
229
2/2
✓ Branch 0 taken 484096 times.
✓ Branch 1 taken 171454 times.
655550 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
230 }
231
232 1588819 bool enemy::overpit(enemy *e)
233 {
234
2/2
✓ Branch 0 taken 1585651 times.
✓ Branch 1 taken 20086672 times.
21672323 for ( int32_t q = 0; q < hxsz; ++q )
235 {
236
2/2
✓ Branch 0 taken 194455660 times.
✓ Branch 1 taken 20083504 times.
214539164 for ( int32_t q = 0; q < hysz; ++q )
237 {
238 //check every pixel of the hitbox
239
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 194452492 times.
194455660 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
240 {
241 //if the hitbox is over a pit, we can't land
242 3168 return true;
243 }
244 194452492 }
245 20083504 }
246 1585651 return false;
247 1588819 }
248
249 3194659 bool enemy::shadow_overpit(enemy *e)
250 {
251
2/2
✓ Branch 0 taken 3190807 times.
✓ Branch 1 taken 48911384 times.
52102191 for ( int32_t q = 0; q < hxsz; ++q )
252 {
253
2/2
✓ Branch 0 taken 738706875 times.
✓ Branch 1 taken 48907532 times.
787614407 for ( int32_t q = 0; q < hysz; ++q )
254 {
255 //check every pixel of the hitbox
256
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 738703023 times.
738706875 if ( ispitfall(x+q+hxofs, y+q+hyofs+hysz-2) )
257 {
258 //if the hitbox is over a pit, we can't land
259 3852 return true;
260 }
261 738703023 }
262 48907532 }
263 3190807 return false;
264 3194659 }
265
266 // Returns true iff a combo type or flag precludes enemy movement.
267 2724844 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
268 {
269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2724844 times.
2724844 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
270 2724844 int32_t c = COMBOTYPE(dx,dy);
271
4/4
✓ Branch 0 taken 1770128 times.
✓ Branch 1 taken 954716 times.
✓ Branch 2 taken 288848 times.
✓ Branch 3 taken 665868 times.
3679560 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
272
3/6
✓ Branch 0 taken 940916 times.
✓ Branch 1 taken 1783928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 940916 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2724844 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_bit(quest_rules,qr_DROWN));
273
4/6
✓ Branch 0 taken 976369 times.
✓ Branch 1 taken 1748475 times.
✓ Branch 2 taken 976369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 976369 times.
✗ Branch 5 not taken.
5450169 return c==cPIT || c==cPITB || c==cPITC ||
274
4/6
✓ Branch 0 taken 976369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 976369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 875797 times.
✓ Branch 5 taken 100572 times.
976369 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
275 // Block enemies type and block enemies flags
276
2/2
✓ Branch 0 taken 975050 times.
✓ Branch 1 taken 874478 times.
100572 combo_class_buf[c].block_enemies&1 ||
277
3/4
✓ Branch 0 taken 975048 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 975048 times.
✗ Branch 3 not taken.
975050 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
278
4/4
✓ Branch 0 taken 974829 times.
✓ Branch 1 taken 219 times.
✓ Branch 2 taken 974819 times.
✓ Branch 3 taken 10 times.
975048 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
279 // Check for ladder-only combos which aren't dried water
280
3/4
✓ Branch 0 taken 639 times.
✓ Branch 1 taken 974180 times.
✓ Branch 2 taken 639 times.
✗ Branch 3 not taken.
1949638 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
281 // Check for drownable water
282
4/4
✓ Branch 0 taken 123963 times.
✓ Branch 1 taken 850856 times.
✓ Branch 2 taken 14620 times.
✓ Branch 3 taken 109343 times.
974819 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
283 976850 }
284
285 // Returns true iff enemy is floating and blocked by a combo type or flag.
286 3539853 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
287 {
288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3539853 times.
3539853 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
289
4/4
✓ Branch 0 taken 2764890 times.
✓ Branch 1 taken 774963 times.
✓ Branch 2 taken 546911 times.
✓ Branch 3 taken 228052 times.
4314816 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
290
3/4
✓ Branch 0 taken 2774894 times.
✓ Branch 1 taken 764959 times.
✓ Branch 2 taken 764959 times.
✗ Branch 3 not taken.
4304812 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
291
2/2
✓ Branch 0 taken 412903 times.
✓ Branch 1 taken 3126950 times.
6666803 return ((special==spw_floater)&&
292
2/2
✓ Branch 0 taken 3120839 times.
✓ Branch 1 taken 6111 times.
3126950 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
293
1/2
✓ Branch 0 taken 3120839 times.
✗ Branch 1 not taken.
3120839 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
294
1/2
✓ Branch 0 taken 3120839 times.
✗ Branch 1 not taken.
3120839 (MAPFLAG(dx,dy)==mfNOENEMY)||
295
1/2
✓ Branch 0 taken 3120839 times.
✗ Branch 1 not taken.
3120839 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
296
4/4
✓ Branch 0 taken 411425 times.
✓ Branch 1 taken 2709414 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 411218 times.
6241471 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
297
2/2
✓ Branch 0 taken 2702951 times.
✓ Branch 1 taken 417681 times.
3120632 (pit_blocks && ispitfall(dx,dy))));
298 3539853 }
299 // Returns true iff a combo type or flag precludes enemy movement.
300 229849 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
301 {
302 229849 int32_t c = COMBOTYPE(dx,dy);
303 229849 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
304
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 202524 times.
229849 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_bit(quest_rules,qr_DROWN);
305
3/6
✓ Branch 0 taken 229849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 229849 times.
✗ Branch 5 not taken.
871312 return c==cPIT || c==cPITB || c==cPITC ||
306
4/6
✓ Branch 0 taken 229849 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229849 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 205814 times.
✓ Branch 5 taken 24035 times.
229849 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
307 // Block enemies type and block enemies flags
308
2/2
✓ Branch 0 taken 229842 times.
✓ Branch 1 taken 205807 times.
24035 combo_class_buf[c].block_enemies&1 ||
309
3/4
✓ Branch 0 taken 229723 times.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 229723 times.
✗ Branch 3 not taken.
229842 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
310
3/4
✓ Branch 0 taken 226255 times.
✓ Branch 1 taken 3468 times.
✓ Branch 2 taken 226255 times.
✗ Branch 3 not taken.
229723 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
311 // Check for ladder-only combos which aren't dried water
312
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 226220 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
452510 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
313 // Check for drownable water
314
4/4
✓ Branch 0 taken 33520 times.
✓ Branch 1 taken 192735 times.
✓ Branch 2 taken 25138 times.
✓ Branch 3 taken 8382 times.
226255 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
315 }
316
317 // Returns true iff enemy is floating and blocked by a combo type or flag.
318 113422 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
319 {
320
2/2
✓ Branch 0 taken 112869 times.
✓ Branch 1 taken 553 times.
113422 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
321 113422 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113422 times.
226844 return ((special==spw_floater)&&
323
1/2
✓ Branch 0 taken 113422 times.
✗ Branch 1 not taken.
113422 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
324
1/2
✓ Branch 0 taken 113422 times.
✗ Branch 1 not taken.
113422 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
325
1/2
✓ Branch 0 taken 113422 times.
✗ Branch 1 not taken.
113422 (MAPFLAG(dx,dy)==mfNOENEMY)||
326
1/2
✓ Branch 0 taken 113422 times.
✗ Branch 1 not taken.
113422 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
327
4/4
✓ Branch 0 taken 553 times.
✓ Branch 1 taken 112869 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 544 times.
226835 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
328
2/2
✓ Branch 0 taken 112869 times.
✓ Branch 1 taken 544 times.
113413 (pit_blocks && ispitfall(dx,dy))));
329 }
330
331 /**********************************/
332 /******* Enemy Base Class *******/
333 /**********************************/
334
335 /* ROM data flags
336
337 */
338
339 eFire::eFire(eFire const & other, bool new_script_uid, bool clear_parent_script_UID):
340 //Struct Element Type Purpose
341 //sprite(other),
342 enemy(other),
343 clk4(other.clk4),
344 shield(other.shield)
345
346 {
347
348 //arrays
349
350 if(other.scrmem)
351 {
352 alloc_scriptmem();
353 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
354
355 scrmem->scriptData = other.scrmem->scriptData;
356 }
357 else scrmem = NULL;
358 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
359 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
360
361 for(int32_t i=0; i<edefLAST255; i++)
362 defense[i]=other.defense[i];
363 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
364 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
365
366 if(new_script_uid)
367 {
368 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
369 }
370 if(clear_parent_script_UID)
371 {
372 parent_script_UID = 0;
373 }
374 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
375 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
376
377 for ( int32_t q = 0; q < 8; q++ )
378 {
379 initD[q] = other.initD[q];
380 weap_initiald[q] = other.weap_initiald[q];
381 }
382 for ( int32_t q = 0; q < 2; q++ )
383 {
384 initA[q] = other.initA[q];
385 weap_initiala[q] = other.weap_initiala[q];
386 }
387 }
388
389 eOther::eOther(eOther const & other, bool new_script_uid, bool clear_parent_script_UID):
390 //Struct Element Type Purpose
391 //sprite(other),
392 enemy(other),
393 clk4(other.clk4),
394 shield(other.shield)
395
396 {
397
398 //arrays
399
400 if(other.scrmem)
401 {
402 alloc_scriptmem();
403 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
404
405 scrmem->scriptData = other.scrmem->scriptData;
406 }
407 else scrmem = NULL;
408 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
409 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
410
411 for(int32_t i=0; i<edefLAST255; i++)
412 defense[i]=other.defense[i];
413 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
414 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
415
416 if(new_script_uid)
417 {
418 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
419 }
420 if(clear_parent_script_UID)
421 {
422 parent_script_UID = 0;
423 }
424 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
425 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
426
427 for ( int32_t q = 0; q < 8; q++ )
428 {
429 initD[q] = other.initD[q];
430 weap_initiald[q] = other.weap_initiald[q];
431 }
432 for ( int32_t q = 0; q < 2; q++ )
433 {
434 initA[q] = other.initA[q];
435 weap_initiala[q] = other.weap_initiala[q];
436 }
437 }
438
439
440
441
442 eScript::eScript(eScript const & other, bool new_script_uid, bool clear_parent_script_UID):
443 //Struct Element Type Purpose
444 //sprite(other),
445 enemy(other),
446 clk4(other.clk4),
447 shield(other.shield)
448
449 {
450
451 //arrays
452
453 if(other.scrmem)
454 {
455 alloc_scriptmem();
456 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
457
458 scrmem->scriptData = other.scrmem->scriptData;
459 }
460 else scrmem = NULL;
461 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
462 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
463
464 for(int32_t i=0; i<edefLAST255; i++)
465 defense[i]=other.defense[i];
466 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
467 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
468
469 if(new_script_uid)
470 {
471 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
472 }
473 if(clear_parent_script_UID)
474 {
475 parent_script_UID = 0;
476 }
477 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
478 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
479
480 for ( int32_t q = 0; q < 8; q++ )
481 {
482 initD[q] = other.initD[q];
483 weap_initiald[q] = other.weap_initiald[q];
484 }
485 for ( int32_t q = 0; q < 2; q++ )
486 {
487 initA[q] = other.initA[q];
488 weap_initiala[q] = other.weap_initiala[q];
489 }
490 }
491
492 eFriendly::eFriendly(eFriendly const & other, bool new_script_uid, bool clear_parent_script_UID):
493 //Struct Element Type Purpose
494 //sprite(other),
495 enemy(other),
496 clk4(other.clk4),
497 shield(other.shield)
498
499 {
500
501 //arrays
502
503 if(other.scrmem)
504 {
505 alloc_scriptmem();
506 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
507
508 scrmem->scriptData = other.scrmem->scriptData;
509 }
510 else scrmem = NULL;
511 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
512 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
513
514 for(int32_t i=0; i<edefLAST255; i++)
515 defense[i]=other.defense[i];
516 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
517 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
518
519 if(new_script_uid)
520 {
521 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
522 }
523 if(clear_parent_script_UID)
524 {
525 parent_script_UID = 0;
526 }
527 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
528 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
529
530 for ( int32_t q = 0; q < 8; q++ )
531 {
532 initD[q] = other.initD[q];
533 weap_initiald[q] = other.weap_initiald[q];
534 }
535 for ( int32_t q = 0; q < 2; q++ )
536 {
537 initA[q] = other.initA[q];
538 weap_initiala[q] = other.weap_initiala[q];
539 }
540 }
541
542 eGhini::eGhini(eGhini const & other, bool new_script_uid, bool clear_parent_script_UID):
543 //Struct Element Type Purpose
544 //sprite(other),
545 enemy(other),
546 clk4(other.clk4),
547 ox(other.ox),
548 oy(other.oy),
549 c(other.c)
550
551 {
552
553 //arrays
554
555 if(other.scrmem)
556 {
557 alloc_scriptmem();
558 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
559
560 scrmem->scriptData = other.scrmem->scriptData;
561 }
562 else scrmem = NULL;
563 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
564 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
565
566 for(int32_t i=0; i<edefLAST255; i++)
567 defense[i]=other.defense[i];
568 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
569 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
570
571 if(new_script_uid)
572 {
573 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
574 }
575 if(clear_parent_script_UID)
576 {
577 parent_script_UID = 0;
578 }
579 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
580 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
581
582 for ( int32_t q = 0; q < 8; q++ )
583 {
584 initD[q] = other.initD[q];
585 weap_initiald[q] = other.weap_initiald[q];
586 }
587 for ( int32_t q = 0; q < 2; q++ )
588 {
589 initA[q] = other.initA[q];
590 weap_initiala[q] = other.weap_initiala[q];
591 }
592 }
593
594 eTektite::eTektite(eTektite const & other, bool new_script_uid, bool clear_parent_script_UID):
595 //Struct Element Type Purpose
596 //sprite(other),
597 enemy(other),
598 old_y(other.old_y),
599 clk2start(other.clk2start),
600 cstart(other.cstart),
601 c(other.c)
602
603 {
604
605 //arrays
606
607 if(other.scrmem)
608 {
609 alloc_scriptmem();
610 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
611
612 scrmem->scriptData = other.scrmem->scriptData;
613 }
614 else scrmem = NULL;
615 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
616 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
617
618 for(int32_t i=0; i<edefLAST255; i++)
619 defense[i]=other.defense[i];
620 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
621 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
622
623 if(new_script_uid)
624 {
625 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
626 }
627 if(clear_parent_script_UID)
628 {
629 parent_script_UID = 0;
630 }
631 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
632 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
633
634 for ( int32_t q = 0; q < 8; q++ )
635 {
636 initD[q] = other.initD[q];
637 weap_initiald[q] = other.weap_initiald[q];
638 }
639 for ( int32_t q = 0; q < 2; q++ )
640 {
641 initA[q] = other.initA[q];
642 weap_initiala[q] = other.weap_initiala[q];
643 }
644 }
645
646 eItemFairy::eItemFairy(eItemFairy const & other, bool new_script_uid, bool clear_parent_script_UID):
647 //Struct Element Type Purpose
648 //sprite(other),
649 enemy(other)
650 {
651
652 //arrays
653
654 if(other.scrmem)
655 {
656 alloc_scriptmem();
657 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
658
659 scrmem->scriptData = other.scrmem->scriptData;
660 }
661 else scrmem = NULL;
662 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
663 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
664
665 for(int32_t i=0; i<edefLAST255; i++)
666 defense[i]=other.defense[i];
667 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
668 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
669
670 if(new_script_uid)
671 {
672 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
673 }
674 if(clear_parent_script_UID)
675 {
676 parent_script_UID = 0;
677 }
678 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
679 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
680
681 for ( int32_t q = 0; q < 8; q++ )
682 {
683 initD[q] = other.initD[q];
684 weap_initiald[q] = other.weap_initiald[q];
685 }
686 for ( int32_t q = 0; q < 2; q++ )
687 {
688 initA[q] = other.initA[q];
689 weap_initiala[q] = other.weap_initiala[q];
690 }
691 }
692
693 ePeahat::ePeahat(ePeahat const & other, bool new_script_uid, bool clear_parent_script_UID):
694 //Struct Element Type Purpose
695 //sprite(other),
696 enemy(other),
697 ox(other.ox),
698 oy(other.oy),
699 c(other.c)
700 {
701
702 //arrays
703
704 if(other.scrmem)
705 {
706 alloc_scriptmem();
707 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
708
709 scrmem->scriptData = other.scrmem->scriptData;
710 }
711 else scrmem = NULL;
712 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
713 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
714
715 for(int32_t i=0; i<edefLAST255; i++)
716 defense[i]=other.defense[i];
717 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
718 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
719
720 if(new_script_uid)
721 {
722 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
723 }
724 if(clear_parent_script_UID)
725 {
726 parent_script_UID = 0;
727 }
728 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
729 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
730
731 for ( int32_t q = 0; q < 8; q++ )
732 {
733 initD[q] = other.initD[q];
734 weap_initiald[q] = other.weap_initiald[q];
735 }
736 for ( int32_t q = 0; q < 2; q++ )
737 {
738 initA[q] = other.initA[q];
739 weap_initiala[q] = other.weap_initiala[q];
740 }
741 }
742
743 eLeever::eLeever(eLeever const & other, bool new_script_uid, bool clear_parent_script_UID):
744 //Struct Element Type Purpose
745 //sprite(other),
746 enemy(other),
747 temprule(other.temprule)
748 {
749
750 //arrays
751
752 if(other.scrmem)
753 {
754 alloc_scriptmem();
755 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
756
757 scrmem->scriptData = other.scrmem->scriptData;
758 }
759 else scrmem = NULL;
760 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
761 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
762
763 for(int32_t i=0; i<edefLAST255; i++)
764 defense[i]=other.defense[i];
765 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
766 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
767
768 if(new_script_uid)
769 {
770 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
771 }
772 if(clear_parent_script_UID)
773 {
774 parent_script_UID = 0;
775 }
776 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
777 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
778
779 for ( int32_t q = 0; q < 8; q++ )
780 {
781 initD[q] = other.initD[q];
782 weap_initiald[q] = other.weap_initiald[q];
783 }
784 for ( int32_t q = 0; q < 2; q++ )
785 {
786 initA[q] = other.initA[q];
787 weap_initiala[q] = other.weap_initiala[q];
788 }
789 }
790
791 eWallM::eWallM(eWallM const & other, bool new_script_uid, bool clear_parent_script_UID):
792 //Struct Element Type Purpose
793 //sprite(other),
794 enemy(other)
795 {
796
797 //arrays
798
799 if(other.scrmem)
800 {
801 alloc_scriptmem();
802 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
803
804 scrmem->scriptData = other.scrmem->scriptData;
805 }
806 else scrmem = NULL;
807 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
808 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
809
810 for(int32_t i=0; i<edefLAST255; i++)
811 defense[i]=other.defense[i];
812 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
813 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
814
815 if(new_script_uid)
816 {
817 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
818 }
819 if(clear_parent_script_UID)
820 {
821 parent_script_UID = 0;
822 }
823 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
824 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
825
826 for ( int32_t q = 0; q < 8; q++ )
827 {
828 initD[q] = other.initD[q];
829 weap_initiald[q] = other.weap_initiald[q];
830 }
831 for ( int32_t q = 0; q < 2; q++ )
832 {
833 initA[q] = other.initA[q];
834 weap_initiala[q] = other.weap_initiala[q];
835 }
836 }
837
838 eStalfos::eStalfos(eStalfos const & other, bool new_script_uid, bool clear_parent_script_UID):
839 //Struct Element Type Purpose
840 //sprite(other),
841 enemy(other),
842 clk4(other.clk4),
843 clk5(other.clk5),
844 fired(other.fired),
845 shield(other.shield),
846 dashing(other.dashing),
847 multishot(other.multishot),
848 fy(other.fy),
849 shadowdistance(other.shadowdistance)
850 {
851
852 //arrays
853
854 if(other.scrmem)
855 {
856 alloc_scriptmem();
857 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
858
859 scrmem->scriptData = other.scrmem->scriptData;
860 }
861 else scrmem = NULL;
862 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
863 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
864
865 for(int32_t i=0; i<edefLAST255; i++)
866 defense[i]=other.defense[i];
867 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
868 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
869
870 if(new_script_uid)
871 {
872 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
873 }
874 if(clear_parent_script_UID)
875 {
876 parent_script_UID = 0;
877 }
878 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
879 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
880
881 for ( int32_t q = 0; q < 8; q++ )
882 {
883 initD[q] = other.initD[q];
884 weap_initiald[q] = other.weap_initiald[q];
885 }
886 for ( int32_t q = 0; q < 2; q++ )
887 {
888 initA[q] = other.initA[q];
889 weap_initiala[q] = other.weap_initiala[q];
890 }
891 }
892
893 eZora::eZora(eZora const & other, bool new_script_uid, bool clear_parent_script_UID):
894 //Struct Element Type Purpose
895 //sprite(other),
896 enemy(other)
897 {
898
899 //arrays
900
901 if(other.scrmem)
902 {
903 alloc_scriptmem();
904 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
905
906 scrmem->scriptData = other.scrmem->scriptData;
907 }
908 else scrmem = NULL;
909 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
910 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
911
912 for(int32_t i=0; i<edefLAST255; i++)
913 defense[i]=other.defense[i];
914 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
915 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
916
917 if(new_script_uid)
918 {
919 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
920 }
921 if(clear_parent_script_UID)
922 {
923 parent_script_UID = 0;
924 }
925 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
926 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
927
928 for ( int32_t q = 0; q < 8; q++ )
929 {
930 initD[q] = other.initD[q];
931 weap_initiald[q] = other.weap_initiald[q];
932 }
933 for ( int32_t q = 0; q < 2; q++ )
934 {
935 initA[q] = other.initA[q];
936 weap_initiala[q] = other.weap_initiala[q];
937 }
938 }
939
940 eSpinTile::eSpinTile(eSpinTile const & other, bool new_script_uid, bool clear_parent_script_UID):
941 //Struct Element Type Purpose
942 //sprite(other),
943 enemy(other)
944 {
945
946 //arrays
947
948 if(other.scrmem)
949 {
950 alloc_scriptmem();
951 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
952
953 scrmem->scriptData = other.scrmem->scriptData;
954 }
955 else scrmem = NULL;
956 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
957 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
958
959 for(int32_t i=0; i<edefLAST255; i++)
960 defense[i]=other.defense[i];
961 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
962 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
963
964 if(new_script_uid)
965 {
966 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
967 }
968 if(clear_parent_script_UID)
969 {
970 parent_script_UID = 0;
971 }
972 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
973 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
974
975 for ( int32_t q = 0; q < 8; q++ )
976 {
977 initD[q] = other.initD[q];
978 weap_initiald[q] = other.weap_initiald[q];
979 }
980 for ( int32_t q = 0; q < 2; q++ )
981 {
982 initA[q] = other.initA[q];
983 weap_initiala[q] = other.weap_initiala[q];
984 }
985 }
986
987 eNPC::eNPC(eNPC const & other, bool new_script_uid, bool clear_parent_script_UID):
988 //Struct Element Type Purpose
989 //sprite(other),
990 enemy(other)
991 {
992
993 //arrays
994
995 if(other.scrmem)
996 {
997 alloc_scriptmem();
998 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
999
1000 scrmem->scriptData = other.scrmem->scriptData;
1001 }
1002 else scrmem = NULL;
1003 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1004 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1005
1006 for(int32_t i=0; i<edefLAST255; i++)
1007 defense[i]=other.defense[i];
1008 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1009 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1010
1011 if(new_script_uid)
1012 {
1013 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1014 }
1015 if(clear_parent_script_UID)
1016 {
1017 parent_script_UID = 0;
1018 }
1019 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1020 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1021
1022 for ( int32_t q = 0; q < 8; q++ )
1023 {
1024 initD[q] = other.initD[q];
1025 weap_initiald[q] = other.weap_initiald[q];
1026 }
1027 for ( int32_t q = 0; q < 2; q++ )
1028 {
1029 initA[q] = other.initA[q];
1030 weap_initiala[q] = other.weap_initiala[q];
1031 }
1032 }
1033
1034 eTrigger::eTrigger(eTrigger const & other, bool new_script_uid, bool clear_parent_script_UID):
1035 //Struct Element Type Purpose
1036 //sprite(other),
1037 enemy(other)
1038 {
1039
1040 //arrays
1041
1042 if(other.scrmem)
1043 {
1044 alloc_scriptmem();
1045 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1046
1047 scrmem->scriptData = other.scrmem->scriptData;
1048 }
1049 else scrmem = NULL;
1050 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1051 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1052
1053 for(int32_t i=0; i<edefLAST255; i++)
1054 defense[i]=other.defense[i];
1055 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1056 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1057
1058 if(new_script_uid)
1059 {
1060 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1061 }
1062 if(clear_parent_script_UID)
1063 {
1064 parent_script_UID = 0;
1065 }
1066 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1067 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1068
1069 for ( int32_t q = 0; q < 8; q++ )
1070 {
1071 initD[q] = other.initD[q];
1072 weap_initiald[q] = other.weap_initiald[q];
1073 }
1074 for ( int32_t q = 0; q < 2; q++ )
1075 {
1076 initA[q] = other.initA[q];
1077 weap_initiala[q] = other.weap_initiala[q];
1078 }
1079 }
1080
1081 eProjectile::eProjectile(eProjectile const & other, bool new_script_uid, bool clear_parent_script_UID):
1082 //Struct Element Type Purpose
1083 //sprite(other),
1084 enemy(other),
1085 minRange(other.minRange)
1086 {
1087
1088 //arrays
1089
1090 if(other.scrmem)
1091 {
1092 alloc_scriptmem();
1093 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1094
1095 scrmem->scriptData = other.scrmem->scriptData;
1096 }
1097 else scrmem = NULL;
1098 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1099 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1100
1101 for(int32_t i=0; i<edefLAST255; i++)
1102 defense[i]=other.defense[i];
1103 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1104 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1105
1106 if(new_script_uid)
1107 {
1108 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1109 }
1110 if(clear_parent_script_UID)
1111 {
1112 parent_script_UID = 0;
1113 }
1114 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1115 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1116
1117 for ( int32_t q = 0; q < 8; q++ )
1118 {
1119 initD[q] = other.initD[q];
1120 weap_initiald[q] = other.weap_initiald[q];
1121 }
1122 for ( int32_t q = 0; q < 2; q++ )
1123 {
1124 initA[q] = other.initA[q];
1125 weap_initiala[q] = other.weap_initiala[q];
1126 }
1127 }
1128
1129 eBoulder::eBoulder(eBoulder const & other, bool new_script_uid, bool clear_parent_script_UID):
1130 //Struct Element Type Purpose
1131 //sprite(other),
1132 enemy(other)
1133 {
1134
1135 //arrays
1136
1137 if(other.scrmem)
1138 {
1139 alloc_scriptmem();
1140 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1141
1142 scrmem->scriptData = other.scrmem->scriptData;
1143 }
1144 else scrmem = NULL;
1145 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1146 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1147
1148 for(int32_t i=0; i<edefLAST255; i++)
1149 defense[i]=other.defense[i];
1150 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1151 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1152
1153 if(new_script_uid)
1154 {
1155 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1156 }
1157 if(clear_parent_script_UID)
1158 {
1159 parent_script_UID = 0;
1160 }
1161 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1162 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1163
1164 for ( int32_t q = 0; q < 8; q++ )
1165 {
1166 initD[q] = other.initD[q];
1167 weap_initiald[q] = other.weap_initiald[q];
1168 }
1169 for ( int32_t q = 0; q < 2; q++ )
1170 {
1171 initA[q] = other.initA[q];
1172 weap_initiala[q] = other.weap_initiala[q];
1173 }
1174 }
1175
1176 eRock::eRock(eRock const & other, bool new_script_uid, bool clear_parent_script_UID):
1177 //Struct Element Type Purpose
1178 //sprite(other),
1179 enemy(other)
1180 {
1181
1182 //arrays
1183
1184 if(other.scrmem)
1185 {
1186 alloc_scriptmem();
1187 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1188
1189 scrmem->scriptData = other.scrmem->scriptData;
1190 }
1191 else scrmem = NULL;
1192 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1193 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1194
1195 for(int32_t i=0; i<edefLAST255; i++)
1196 defense[i]=other.defense[i];
1197 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1198 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1199
1200 if(new_script_uid)
1201 {
1202 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1203 }
1204 if(clear_parent_script_UID)
1205 {
1206 parent_script_UID = 0;
1207 }
1208 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1209 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1210
1211 for ( int32_t q = 0; q < 8; q++ )
1212 {
1213 initD[q] = other.initD[q];
1214 weap_initiald[q] = other.weap_initiald[q];
1215 }
1216 for ( int32_t q = 0; q < 2; q++ )
1217 {
1218 initA[q] = other.initA[q];
1219 weap_initiala[q] = other.weap_initiala[q];
1220 }
1221 }
1222
1223 eTrap2::eTrap2(eTrap2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1224 //Struct Element Type Purpose
1225 //sprite(other),
1226 enemy(other)
1227 {
1228
1229 //arrays
1230
1231 if(other.scrmem)
1232 {
1233 alloc_scriptmem();
1234 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1235
1236 scrmem->scriptData = other.scrmem->scriptData;
1237 }
1238 else scrmem = NULL;
1239 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1240 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1241
1242 for(int32_t i=0; i<edefLAST255; i++)
1243 defense[i]=other.defense[i];
1244 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1245 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1246
1247 if(new_script_uid)
1248 {
1249 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1250 }
1251 if(clear_parent_script_UID)
1252 {
1253 parent_script_UID = 0;
1254 }
1255 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1256 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1257
1258 for ( int32_t q = 0; q < 8; q++ )
1259 {
1260 initD[q] = other.initD[q];
1261 weap_initiald[q] = other.weap_initiald[q];
1262 }
1263 for ( int32_t q = 0; q < 2; q++ )
1264 {
1265 initA[q] = other.initA[q];
1266 weap_initiala[q] = other.weap_initiala[q];
1267 }
1268 }
1269
1270 eTrap::eTrap(eTrap const & other, bool new_script_uid, bool clear_parent_script_UID):
1271 //Struct Element Type Purpose
1272 //sprite(other),
1273 enemy(other),
1274 ox(other.ox),
1275 oy(other.oy)
1276 {
1277
1278 //arrays
1279
1280 if(other.scrmem)
1281 {
1282 alloc_scriptmem();
1283 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1284
1285 scrmem->scriptData = other.scrmem->scriptData;
1286 }
1287 else scrmem = NULL;
1288 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1289 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1290
1291 for(int32_t i=0; i<edefLAST255; i++)
1292 defense[i]=other.defense[i];
1293 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1294 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1295
1296 if(new_script_uid)
1297 {
1298 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1299 }
1300 if(clear_parent_script_UID)
1301 {
1302 parent_script_UID = 0;
1303 }
1304 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1305 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1306
1307 for ( int32_t q = 0; q < 8; q++ )
1308 {
1309 initD[q] = other.initD[q];
1310 weap_initiald[q] = other.weap_initiald[q];
1311 }
1312 for ( int32_t q = 0; q < 2; q++ )
1313 {
1314 initA[q] = other.initA[q];
1315 weap_initiala[q] = other.weap_initiala[q];
1316 }
1317 }
1318
1319
1320
1321
1322 eKeese::eKeese(eKeese const & other, bool new_script_uid, bool clear_parent_script_UID):
1323 //Struct Element Type Purpose
1324 //sprite(other),
1325 enemy(other),
1326 ox(other.ox),
1327 c(other.c),
1328 clk4(other.clk4),
1329 oy(other.oy)
1330 {
1331
1332 //arrays
1333
1334 if(other.scrmem)
1335 {
1336 alloc_scriptmem();
1337 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1338
1339 scrmem->scriptData = other.scrmem->scriptData;
1340 }
1341 else scrmem = NULL;
1342 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1343 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1344
1345 for(int32_t i=0; i<edefLAST255; i++)
1346 defense[i]=other.defense[i];
1347 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1348 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1349
1350 if(new_script_uid)
1351 {
1352 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1353 }
1354 if(clear_parent_script_UID)
1355 {
1356 parent_script_UID = 0;
1357 }
1358 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1359 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1360
1361 for ( int32_t q = 0; q < 8; q++ )
1362 {
1363 initD[q] = other.initD[q];
1364 weap_initiald[q] = other.weap_initiald[q];
1365 }
1366 for ( int32_t q = 0; q < 2; q++ )
1367 {
1368 initA[q] = other.initA[q];
1369 weap_initiala[q] = other.weap_initiala[q];
1370 }
1371 }
1372
1373 eWizzrobe::eWizzrobe(eWizzrobe const & other, bool new_script_uid, bool clear_parent_script_UID):
1374 //Struct Element Type Purpose
1375 //sprite(other),
1376 enemy(other),
1377 charging(other.charging),
1378 firing(other.firing),
1379 fclk(other.fclk)
1380 {
1381
1382 //arrays
1383
1384 if(other.scrmem)
1385 {
1386 alloc_scriptmem();
1387 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1388
1389 scrmem->scriptData = other.scrmem->scriptData;
1390 }
1391 else scrmem = NULL;
1392 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1393 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1394
1395 for(int32_t i=0; i<edefLAST255; i++)
1396 defense[i]=other.defense[i];
1397 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1398 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1399
1400 if(new_script_uid)
1401 {
1402 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1403 }
1404 if(clear_parent_script_UID)
1405 {
1406 parent_script_UID = 0;
1407 }
1408 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1409 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1410
1411 for ( int32_t q = 0; q < 8; q++ )
1412 {
1413 initD[q] = other.initD[q];
1414 weap_initiald[q] = other.weap_initiald[q];
1415 }
1416 for ( int32_t q = 0; q < 2; q++ )
1417 {
1418 initA[q] = other.initA[q];
1419 weap_initiala[q] = other.weap_initiala[q];
1420 }
1421 }
1422
1423 eDodongo::eDodongo(eDodongo const & other, bool new_script_uid, bool clear_parent_script_UID):
1424 //Struct Element Type Purpose
1425 //sprite(other),
1426 enemy(other)
1427 {
1428
1429 //arrays
1430
1431 if(other.scrmem)
1432 {
1433 alloc_scriptmem();
1434 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1435
1436 scrmem->scriptData = other.scrmem->scriptData;
1437 }
1438 else scrmem = NULL;
1439 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1440 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1441
1442 for(int32_t i=0; i<edefLAST255; i++)
1443 defense[i]=other.defense[i];
1444 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1445 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1446
1447 if(new_script_uid)
1448 {
1449 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1450 }
1451 if(clear_parent_script_UID)
1452 {
1453 parent_script_UID = 0;
1454 }
1455 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1456 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1457
1458 for ( int32_t q = 0; q < 8; q++ )
1459 {
1460 initD[q] = other.initD[q];
1461 weap_initiald[q] = other.weap_initiald[q];
1462 }
1463 for ( int32_t q = 0; q < 2; q++ )
1464 {
1465 initA[q] = other.initA[q];
1466 weap_initiala[q] = other.weap_initiala[q];
1467 }
1468 }
1469
1470 eDodongo2::eDodongo2(eDodongo2 const & other, bool new_script_uid, bool clear_parent_script_UID):
1471 //Struct Element Type Purpose
1472 //sprite(other),
1473 enemy(other),
1474 previous_dir(other.previous_dir)
1475 {
1476
1477 //arrays
1478
1479 if(other.scrmem)
1480 {
1481 alloc_scriptmem();
1482 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1483
1484 scrmem->scriptData = other.scrmem->scriptData;
1485 }
1486 else scrmem = NULL;
1487 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1488 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1489
1490 for(int32_t i=0; i<edefLAST255; i++)
1491 defense[i]=other.defense[i];
1492 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1493 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1494
1495 if(new_script_uid)
1496 {
1497 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1498 }
1499 if(clear_parent_script_UID)
1500 {
1501 parent_script_UID = 0;
1502 }
1503 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1504 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1505
1506 for ( int32_t q = 0; q < 8; q++ )
1507 {
1508 initD[q] = other.initD[q];
1509 weap_initiald[q] = other.weap_initiald[q];
1510 }
1511 for ( int32_t q = 0; q < 2; q++ )
1512 {
1513 initA[q] = other.initA[q];
1514 weap_initiala[q] = other.weap_initiala[q];
1515 }
1516 }
1517
1518 eAquamentus::eAquamentus(eAquamentus const & other, bool new_script_uid, bool clear_parent_script_UID):
1519 //Struct Element Type Purpose
1520 //sprite(other),
1521 enemy(other),
1522 fbx(other.fbx),
1523 clk4(other.clk4)
1524 {
1525
1526 //arrays
1527
1528 if(other.scrmem)
1529 {
1530 alloc_scriptmem();
1531 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1532
1533 scrmem->scriptData = other.scrmem->scriptData;
1534 }
1535 else scrmem = NULL;
1536 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1537 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1538
1539 for(int32_t i=0; i<edefLAST255; i++)
1540 defense[i]=other.defense[i];
1541 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1542 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1543
1544 if(new_script_uid)
1545 {
1546 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1547 }
1548 if(clear_parent_script_UID)
1549 {
1550 parent_script_UID = 0;
1551 }
1552 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1553 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1554
1555 for ( int32_t q = 0; q < 8; q++ )
1556 {
1557 initD[q] = other.initD[q];
1558 weap_initiald[q] = other.weap_initiald[q];
1559 }
1560 for ( int32_t q = 0; q < 2; q++ )
1561 {
1562 initA[q] = other.initA[q];
1563 weap_initiala[q] = other.weap_initiala[q];
1564 }
1565 }
1566
1567 eGohma::eGohma(eGohma const & other, bool new_script_uid, bool clear_parent_script_UID):
1568 //Struct Element Type Purpose
1569 //sprite(other),
1570 enemy(other),
1571 clk4(other.clk4)
1572 {
1573
1574 //arrays
1575
1576 if(other.scrmem)
1577 {
1578 alloc_scriptmem();
1579 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1580
1581 scrmem->scriptData = other.scrmem->scriptData;
1582 }
1583 else scrmem = NULL;
1584 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1585 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1586
1587 for(int32_t i=0; i<edefLAST255; i++)
1588 defense[i]=other.defense[i];
1589 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1590 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1591
1592 if(new_script_uid)
1593 {
1594 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1595 }
1596 if(clear_parent_script_UID)
1597 {
1598 parent_script_UID = 0;
1599 }
1600 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1601 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1602
1603 for ( int32_t q = 0; q < 8; q++ )
1604 {
1605 initD[q] = other.initD[q];
1606 weap_initiald[q] = other.weap_initiald[q];
1607 }
1608 for ( int32_t q = 0; q < 2; q++ )
1609 {
1610 initA[q] = other.initA[q];
1611 weap_initiala[q] = other.weap_initiala[q];
1612 }
1613 }
1614
1615 eLilDig::eLilDig(eLilDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1616 //Struct Element Type Purpose
1617 //sprite(other),
1618 enemy(other)
1619 {
1620
1621 //arrays
1622
1623 if(other.scrmem)
1624 {
1625 alloc_scriptmem();
1626 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1627
1628 scrmem->scriptData = other.scrmem->scriptData;
1629 }
1630 else scrmem = NULL;
1631 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1632 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1633
1634 for(int32_t i=0; i<edefLAST255; i++)
1635 defense[i]=other.defense[i];
1636 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1637 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1638
1639 if(new_script_uid)
1640 {
1641 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1642 }
1643 if(clear_parent_script_UID)
1644 {
1645 parent_script_UID = 0;
1646 }
1647 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1648 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1649
1650 for ( int32_t q = 0; q < 8; q++ )
1651 {
1652 initD[q] = other.initD[q];
1653 weap_initiald[q] = other.weap_initiald[q];
1654 }
1655 for ( int32_t q = 0; q < 2; q++ )
1656 {
1657 initA[q] = other.initA[q];
1658 weap_initiala[q] = other.weap_initiala[q];
1659 }
1660 }
1661
1662 eBigDig::eBigDig(eBigDig const & other, bool new_script_uid, bool clear_parent_script_UID):
1663 //Struct Element Type Purpose
1664 //sprite(other),
1665 enemy(other)
1666 {
1667
1668 //arrays
1669
1670 if(other.scrmem)
1671 {
1672 alloc_scriptmem();
1673 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1674
1675 scrmem->scriptData = other.scrmem->scriptData;
1676 }
1677 else scrmem = NULL;
1678 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1679 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1680
1681 for(int32_t i=0; i<edefLAST255; i++)
1682 defense[i]=other.defense[i];
1683 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1684 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1685
1686 if(new_script_uid)
1687 {
1688 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1689 }
1690 if(clear_parent_script_UID)
1691 {
1692 parent_script_UID = 0;
1693 }
1694 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1695 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1696
1697 for ( int32_t q = 0; q < 8; q++ )
1698 {
1699 initD[q] = other.initD[q];
1700 weap_initiald[q] = other.weap_initiald[q];
1701 }
1702 for ( int32_t q = 0; q < 2; q++ )
1703 {
1704 initA[q] = other.initA[q];
1705 weap_initiala[q] = other.weap_initiala[q];
1706 }
1707 }
1708
1709 eGanon::eGanon(eGanon const & other, bool new_script_uid, bool clear_parent_script_UID):
1710 //Struct Element Type Purpose
1711 //sprite(other),
1712 enemy(other),
1713 Stunclk(other.Stunclk)
1714
1715 {
1716
1717 //arrays
1718
1719 if(other.scrmem)
1720 {
1721 alloc_scriptmem();
1722 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1723
1724 scrmem->scriptData = other.scrmem->scriptData;
1725 }
1726 else scrmem = NULL;
1727 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1728 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1729
1730 for(int32_t i=0; i<edefLAST255; i++)
1731 defense[i]=other.defense[i];
1732 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1733 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1734
1735 if(new_script_uid)
1736 {
1737 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1738 }
1739 if(clear_parent_script_UID)
1740 {
1741 parent_script_UID = 0;
1742 }
1743 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1744 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1745
1746 for ( int32_t q = 0; q < 8; q++ )
1747 {
1748 initD[q] = other.initD[q];
1749 weap_initiald[q] = other.weap_initiald[q];
1750 }
1751 for ( int32_t q = 0; q < 2; q++ )
1752 {
1753 initA[q] = other.initA[q];
1754 weap_initiala[q] = other.weap_initiala[q];
1755 }
1756 }
1757
1758 eMoldorm::eMoldorm(eMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1759 //Struct Element Type Purpose
1760 //sprite(other),
1761 enemy(other),
1762 segcnt(other.segcnt),
1763 segid(other.segid)
1764
1765 {
1766
1767 //arrays
1768
1769 if(other.scrmem)
1770 {
1771 alloc_scriptmem();
1772 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1773
1774 scrmem->scriptData = other.scrmem->scriptData;
1775 }
1776 else scrmem = NULL;
1777 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1778 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1779
1780 for(int32_t i=0; i<edefLAST255; i++)
1781 defense[i]=other.defense[i];
1782 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1783 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1784
1785 if(new_script_uid)
1786 {
1787 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1788 }
1789 if(clear_parent_script_UID)
1790 {
1791 parent_script_UID = 0;
1792 }
1793 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1794 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1795
1796 for ( int32_t q = 0; q < 8; q++ )
1797 {
1798 initD[q] = other.initD[q];
1799 weap_initiald[q] = other.weap_initiald[q];
1800 }
1801 for ( int32_t q = 0; q < 2; q++ )
1802 {
1803 initA[q] = other.initA[q];
1804 weap_initiala[q] = other.weap_initiala[q];
1805 }
1806 }
1807
1808 esMoldorm::esMoldorm(esMoldorm const & other, bool new_script_uid, bool clear_parent_script_UID):
1809 //Struct Element Type Purpose
1810 //sprite(other),
1811 enemy(other),
1812 parentclk(other.parentclk)
1813 {
1814
1815 //arrays
1816
1817 if(other.scrmem)
1818 {
1819 alloc_scriptmem();
1820 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1821
1822 scrmem->scriptData = other.scrmem->scriptData;
1823 }
1824 else scrmem = NULL;
1825 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1826 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1827
1828 for(int32_t i=0; i<edefLAST255; i++)
1829 defense[i]=other.defense[i];
1830 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1831 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1832
1833 if(new_script_uid)
1834 {
1835 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1836 }
1837 if(clear_parent_script_UID)
1838 {
1839 parent_script_UID = 0;
1840 }
1841 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1842 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1843
1844 for ( int32_t q = 0; q < 8; q++ )
1845 {
1846 initD[q] = other.initD[q];
1847 weap_initiald[q] = other.weap_initiald[q];
1848 }
1849 for ( int32_t q = 0; q < 2; q++ )
1850 {
1851 initA[q] = other.initA[q];
1852 weap_initiala[q] = other.weap_initiala[q];
1853 }
1854 }
1855 /*
1856 eManhandla::eManhandla(eManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1857 //Struct Element Type Purpose
1858 //sprite(other),
1859 enemy(other),
1860 armcnt(armcnt),
1861 adjusted(adjusted),
1862 arm[0](arm[0]),
1863 arm[1](arm[1]),
1864 arm[2](arm[2]),
1865 arm[3](arm[3]),
1866 arm[4](arm[4]),
1867 arm[5](arm[5]),
1868 arm[6](arm[6]),
1869 arm[7](arm[7])
1870 {
1871
1872 //arrays
1873 if(other.scrmem)
1874 {
1875 alloc_scriptmem();
1876 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1877
1878 scrmem->scriptData = other.scrmem->scriptData;
1879 }
1880 else scrmem = NULL;
1881 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1882 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1883
1884 for(int32_t i=0; i<edefLAST255; i++)
1885 defense[i]=other.defense[i];
1886 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1887 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1888
1889 if(new_script_uid)
1890 {
1891 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1892 }
1893 if(clear_parent_script_UID)
1894 {
1895 parent_script_UID = 0;
1896 }
1897 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1898 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1899
1900 for ( int32_t q = 0; q < 8; q++ )
1901 {
1902 initD[q] = other.initD[q];
1903 weap_initiald[q] = other.weap_initiald[q];
1904 }
1905 for ( int32_t q = 0; q < 2; q++ )
1906 {
1907 initA[q] = other.initA[q];
1908 weap_initiala[q] = other.weap_initiala[q];
1909 }
1910 }
1911
1912 esManhandla::esManhandla(esManhandla const & other, bool new_script_uid, bool clear_parent_script_UID):
1913 //Struct Element Type Purpose
1914 //sprite(other),
1915 enemy(other)
1916 {
1917
1918 //arrays
1919 if(other.scrmem)
1920 {
1921 alloc_scriptmem();
1922 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1923
1924 scrmem->scriptData = other.scrmem->scriptData;
1925 }
1926 else scrmem = NULL;
1927 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1928 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1929
1930 for(int32_t i=0; i<edefLAST255; i++)
1931 defense[i]=other.defense[i];
1932 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1933 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1934
1935 if(new_script_uid)
1936 {
1937 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1938 }
1939 if(clear_parent_script_UID)
1940 {
1941 parent_script_UID = 0;
1942 }
1943 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1944 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1945
1946 for ( int32_t q = 0; q < 8; q++ )
1947 {
1948 initD[q] = other.initD[q];
1949 weap_initiald[q] = other.weap_initiald[q];
1950 }
1951 for ( int32_t q = 0; q < 2; q++ )
1952 {
1953 initA[q] = other.initA[q];
1954 weap_initiala[q] = other.weap_initiala[q];
1955 }
1956 }
1957
1958 eGleeok::eGleeok(eGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
1959 //Struct Element Type Purpose
1960 //sprite(other),
1961 enemy(other),
1962 flameclk(flameclk),
1963 flamehead(flamehead),
1964 necktile(necktile)
1965
1966 {
1967
1968 //arrays
1969
1970 if(other.scrmem)
1971 {
1972 alloc_scriptmem();
1973 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
1974
1975 scrmem->scriptData = other.scrmem->scriptData;
1976 }
1977 else scrmem = NULL;
1978 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
1979 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
1980
1981 for(int32_t i=0; i<edefLAST255; i++)
1982 defense[i]=other.defense[i];
1983 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
1984 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
1985
1986 if(new_script_uid)
1987 {
1988 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
1989 }
1990 if(clear_parent_script_UID)
1991 {
1992 parent_script_UID = 0;
1993 }
1994 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
1995 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
1996
1997 for ( int32_t q = 0; q < 8; q++ )
1998 {
1999 initD[q] = other.initD[q];
2000 weap_initiald[q] = other.weap_initiald[q];
2001 }
2002 for ( int32_t q = 0; q < 2; q++ )
2003 {
2004 initA[q] = other.initA[q];
2005 weap_initiala[q] = other.weap_initiala[q];
2006 }
2007 }
2008
2009 esGleeok::esGleeok(esGleeok const & other, bool new_script_uid, bool clear_parent_script_UID):
2010 //Struct Element Type Purpose
2011 //sprite(other),
2012 enemy(other),
2013 headtile(headtile),
2014 flyingheadtile(flyingheadtile),
2015 necktile(necktile),
2016 xoffset(xoffset),
2017 yoffset(yoffset),
2018 nx(nx),
2019 ny(ny),
2020 nxoffset(nxoffset),
2021 nyoffset(nyoffset),
2022 parent(parent)
2023
2024 {
2025
2026 //arrays
2027
2028 if(other.scrmem)
2029 {
2030 alloc_scriptmem();
2031 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2032
2033 scrmem->scriptData = other.scrmem->scriptData;
2034 }
2035 else scrmem = NULL;
2036 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2037 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2038
2039 //for ( int32_t q = 0; q < 255; q++ )
2040 //{
2041 // nx[q] = other.nx[q];
2042 // ny[q] = other.ny[q];
2043 // nxoffset[q] = other.nxoffset[q];
2044 // nyoffset[q] = other.nyoffset[q];
2045 //}
2046
2047 for(int32_t i=0; i<edefLAST255; i++)
2048 defense[i]=other.defense[i];
2049 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2050 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2051
2052 if(new_script_uid)
2053 {
2054 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2055 }
2056 if(clear_parent_script_UID)
2057 {
2058 parent_script_UID = 0;
2059 }
2060 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2061 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2062
2063 for ( int32_t q = 0; q < 8; q++ )
2064 {
2065 initD[q] = other.initD[q];
2066 weap_initiald[q] = other.weap_initiald[q];
2067 }
2068 for ( int32_t q = 0; q < 2; q++ )
2069 {
2070 initA[q] = other.initA[q];
2071 weap_initiala[q] = other.weap_initiala[q];
2072 }
2073 }
2074
2075 ePatra::ePatra(ePatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2076 //Struct Element Type Purpose
2077 //sprite(other),
2078 enemy(other),
2079 flycnt(flycnt),
2080 flycnt2(flycnt2),
2081 loopcnt(loopcnt),
2082 lookat(lookat),
2083 circle_x(circle_x),
2084 circle_y(circle_y),
2085 temp_x(temp_x),
2086 temp_y(temp_y),
2087 adjusted(adjusted)
2088
2089 {
2090
2091 //arrays
2092
2093 if(other.scrmem)
2094 {
2095 alloc_scriptmem();
2096 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2097
2098 scrmem->scriptData = other.scrmem->scriptData;
2099 }
2100 else scrmem = NULL;
2101 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2102 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2103
2104 for(int32_t i=0; i<edefLAST255; i++)
2105 defense[i]=other.defense[i];
2106 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2107 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2108
2109 if(new_script_uid)
2110 {
2111 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2112 }
2113 if(clear_parent_script_UID)
2114 {
2115 parent_script_UID = 0;
2116 }
2117 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2118 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2119
2120 for ( int32_t q = 0; q < 8; q++ )
2121 {
2122 initD[q] = other.initD[q];
2123 weap_initiald[q] = other.weap_initiald[q];
2124 }
2125 for ( int32_t q = 0; q < 2; q++ )
2126 {
2127 initA[q] = other.initA[q];
2128 weap_initiala[q] = other.weap_initiala[q];
2129 }
2130 }
2131
2132 ePatraBS::ePatraBS(ePatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2133 //Struct Element Type Purpose
2134 //sprite(other),
2135 enemy(other),
2136 flycnt(flycnt),
2137 flycnt2(flycnt2),
2138 loopcnt(loopcnt),
2139 lookat(lookat),
2140 adjusted(adjusted)
2141
2142 {
2143
2144 //arrays
2145
2146 if(other.scrmem)
2147 {
2148 alloc_scriptmem();
2149 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2150
2151 scrmem->scriptData = other.scrmem->scriptData;
2152 }
2153 else scrmem = NULL;
2154 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2155 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2156
2157 for(int32_t i=0; i<edefLAST255; i++)
2158 defense[i]=other.defense[i];
2159 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2160 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2161
2162 if(new_script_uid)
2163 {
2164 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2165 }
2166 if(clear_parent_script_UID)
2167 {
2168 parent_script_UID = 0;
2169 }
2170 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2171 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2172
2173 for ( int32_t q = 0; q < 8; q++ )
2174 {
2175 initD[q] = other.initD[q];
2176 weap_initiald[q] = other.weap_initiald[q];
2177 }
2178 for ( int32_t q = 0; q < 2; q++ )
2179 {
2180 initA[q] = other.initA[q];
2181 weap_initiala[q] = other.weap_initiala[q];
2182 }
2183 }
2184
2185 esPatra::esPatra(esPatra const & other, bool new_script_uid, bool clear_parent_script_UID):
2186 //Struct Element Type Purpose
2187 //sprite(other),
2188 enemy(other)
2189
2190 {
2191
2192 //arrays
2193
2194 if(other.scrmem)
2195 {
2196 alloc_scriptmem();
2197 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2198
2199 scrmem->scriptData = other.scrmem->scriptData;
2200 }
2201 else scrmem = NULL;
2202 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2203 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2204
2205 for ( int32_t q = 0; q < 255; q++ )
2206 {
2207 nx[q] = other.nx[q];
2208 ny[q] = other.ny[q];
2209 nxoffset[q] = other.nxoffset[q];
2210 nyoffset[q] = other.nyoffset[q];
2211 }
2212
2213 for(int32_t i=0; i<edefLAST255; i++)
2214 defense[i]=other.defense[i];
2215 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2216 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2217
2218 if(new_script_uid)
2219 {
2220 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2221 }
2222 if(clear_parent_script_UID)
2223 {
2224 parent_script_UID = 0;
2225 }
2226 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2227 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2228
2229 for ( int32_t q = 0; q < 8; q++ )
2230 {
2231 initD[q] = other.initD[q];
2232 weap_initiald[q] = other.weap_initiald[q];
2233 }
2234 for ( int32_t q = 0; q < 2; q++ )
2235 {
2236 initA[q] = other.initA[q];
2237 weap_initiala[q] = other.weap_initiala[q];
2238 }
2239 }
2240
2241 esPatraBS::esPatraBS(esPatraBS const & other, bool new_script_uid, bool clear_parent_script_UID):
2242 //Struct Element Type Purpose
2243 //sprite(other),
2244 enemy(other)
2245
2246 {
2247
2248 //arrays
2249
2250 if(other.scrmem)
2251 {
2252 alloc_scriptmem();
2253 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2254
2255 scrmem->scriptData = other.scrmem->scriptData;
2256 }
2257 else scrmem = NULL;
2258 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2259 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2260
2261 for ( int32_t q = 0; q < 255; q++ )
2262 {
2263 nx[q] = other.nx[q];
2264 ny[q] = other.ny[q];
2265 nxoffset[q] = other.nxoffset[q];
2266 nyoffset[q] = other.nyoffset[q];
2267 }
2268
2269 for(int32_t i=0; i<edefLAST255; i++)
2270 defense[i]=other.defense[i];
2271 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2272 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2273
2274 if(new_script_uid)
2275 {
2276 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2277 }
2278 if(clear_parent_script_UID)
2279 {
2280 parent_script_UID = 0;
2281 }
2282 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2283 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2284
2285 for ( int32_t q = 0; q < 8; q++ )
2286 {
2287 initD[q] = other.initD[q];
2288 weap_initiald[q] = other.weap_initiald[q];
2289 }
2290 for ( int32_t q = 0; q < 2; q++ )
2291 {
2292 initA[q] = other.initA[q];
2293 weap_initiala[q] = other.weap_initiala[q];
2294 }
2295 }
2296
2297 */
2298
2299
5/10
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37112 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 37112 times.
✗ Branch 9 not taken.
111336 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
2300 74224 {
2301
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 x=X;
2302
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 y=Y;
2303 37112 id=Id;
2304 37112 clk=Clk;
2305
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 floor_y=y;
2306 37112 ceiling=false;
2307 37112 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
2308 37112 grumble = movestatus = posframe = timer = ox = oy = 0;
2309
4/8
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37112 times.
✓ Branch 4 taken 37112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37112 times.
✗ Branch 7 not taken.
37112 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
2310 37112 did_armos=true;
2311 37112 script_spawned=false;
2312
2313 37112 d = guysbuf + (id & 0xFFF);
2314 37112 hp = d->hp;
2315 37112 starting_hp = hp;
2316 // cs = d->cset;
2317 //d variables
2318
2319 37112 flags=d->flags;
2320 37112 flags2=d->flags2;
2321 37112 s_tile=d->s_tile; //secondary (additional) tile(s)
2322 37112 family=d->family;
2323 37112 dcset=d->cset;
2324 37112 cs=dcset;
2325
3/4
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27523 times.
✓ Branch 3 taken 9589 times.
37112 anim=get_bit(quest_rules,qr_NEWENEMYTILES)?d->e_anim:d->anim;
2326 37112 dp=d->dp;
2327 37112 wdp=d->wdp;
2328 37112 wpn=d->weapon;
2329 37112 wpnsprite = d-> wpnsprite; //2.6 -Z
2330 37112 rate=d->rate;
2331 37112 hrate=d->hrate;
2332
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 dstep=d->step;
2333 37112 homing=d->homing;
2334 37112 dmisc1=d->misc1;
2335 37112 dmisc2=d->misc2;
2336 37112 dmisc3=d->misc3;
2337 37112 dmisc4=d->misc4;
2338 37112 dmisc5=d->misc5;
2339 37112 dmisc6=d->misc6;
2340 37112 dmisc7=d->misc7;
2341 37112 dmisc8=d->misc8;
2342 37112 dmisc9=d->misc9;
2343 37112 dmisc10=d->misc10;
2344 37112 dmisc11=d->misc11;
2345 37112 dmisc12=d->misc12;
2346 37112 dmisc13=d->misc13;
2347 37112 dmisc14=d->misc14;
2348 37112 dmisc15=d->misc15;
2349 37112 dmisc16=d->misc16;
2350 37112 dmisc17=d->misc17;
2351 37112 dmisc18=d->misc18;
2352 37112 dmisc19=d->misc19;
2353 37112 dmisc20=d->misc20;
2354 37112 dmisc21=d->misc21;
2355 37112 dmisc22=d->misc22;
2356 37112 dmisc23=d->misc23;
2357 37112 dmisc24=d->misc24;
2358 37112 dmisc25=d->misc25;
2359 37112 dmisc26=d->misc26;
2360 37112 dmisc27=d->misc27;
2361 37112 dmisc28=d->misc28;
2362 37112 dmisc29=d->misc29;
2363 37112 dmisc30=d->misc30;
2364 37112 dmisc31=d->misc31;
2365 37112 dmisc32=d->misc32;
2366
3/4
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36629 times.
✓ Branch 3 taken 483 times.
37112 if (get_bit(quest_rules, qr_BROKEN_ATTRIBUTE_31_32))
2367 {
2368 36629 dmisc31 = dmisc32;
2369 36629 dmisc32 = 0;
2370 36629 }
2371 37112 spr_shadow=d->spr_shadow;
2372 37112 spr_death=d->spr_death;
2373 37112 spr_spawn=d->spr_spawn;
2374
2375
2/2
✓ Branch 0 taken 1521592 times.
✓ Branch 1 taken 37112 times.
1558704 for(int32_t i=0; i<edefLAST255; i++)
2376 1521592 defense[i]=d->defense[i];
2377
2378 37112 bgsfx=d->bgsfx;
2379 37112 hitsfx=d->hitsfx;
2380 37112 deadsfx=d->deadsfx;
2381 37112 bosspal=d->bosspal;
2382 37112 parent_script_UID = 0;
2383
2384 37112 frozentile = d->frozentile;
2385
2386 37112 frozencset = d->frozencset;
2387 37112 frozenclock = 0;
2388
2/2
✓ Branch 0 taken 371120 times.
✓ Branch 1 taken 37112 times.
408232 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
2389
2390
2/2
✓ Branch 0 taken 37112 times.
✓ Branch 1 taken 593792 times.
630904 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
2391 //firesfx = 0; //t.b.a -Z
2392 37112 isCore = true; //t.b.a
2393 37112 parentCore = 0; //t.b.a
2394
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2395
2396 37112 firesfx = d->firesfx;
2397
2/2
✓ Branch 0 taken 1187584 times.
✓ Branch 1 taken 37112 times.
1224696 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
2398
2/2
✓ Branch 0 taken 1187584 times.
✓ Branch 1 taken 37112 times.
1224696 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
2399
2400
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
2401 37112 waitdraw = 0;
2402
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
2403
2404
2/2
✓ Branch 0 taken 296896 times.
✓ Branch 1 taken 37112 times.
334008 for ( int32_t q = 0; q < 8; q++ )
2405 {
2406 296896 initD[q] = d->initD[q];
2407 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
2408 296896 weap_initiald[q] = d->weap_initiald[q];
2409 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
2410 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
2411 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
2412 296896 }
2413
2/2
✓ Branch 0 taken 74224 times.
✓ Branch 1 taken 37112 times.
111336 for ( int32_t q = 0; q < 2; q++ )
2414 {
2415 74224 initA[q] = d->initA[q];
2416 74224 weap_initiala[q] = d->weap_initiala[q];
2417 74224 }
2418
2419 37112 stickclk = 0;
2420 37112 submerged = false;
2421 37112 ffcactivated = 0;
2422 37112 hitdir = -1;
2423 37112 dialogue_str = 0; //set by spawn flags.
2424 37112 editorflags = d->editorflags; //set by Enemy Editor
2425 //Set the drawing flag for this sprite.
2426
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
2427
2428
2429
2/2
✓ Branch 0 taken 7349 times.
✓ Branch 1 taken 29763 times.
37112 if(bosspal>-1)
2430 {
2431
1/2
✓ Branch 0 taken 7349 times.
✗ Branch 1 not taken.
7349 loadpalset(csBOSS,pSprite(bosspal));
2432 7349 }
2433
2434
2/2
✓ Branch 0 taken 21032 times.
✓ Branch 1 taken 16080 times.
37112 if(bgsfx>-1)
2435 {
2436
1/2
✓ Branch 0 taken 21032 times.
✗ Branch 1 not taken.
21032 cont_sfx(bgsfx);
2437 21032 }
2438
2439
3/4
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27523 times.
✓ Branch 3 taken 9589 times.
37112 if(get_bit(quest_rules,qr_NEWENEMYTILES))
2440 {
2441 27523 o_tile=d->e_tile;
2442 27523 frate = d->e_frate;
2443 27523 }
2444 else
2445 {
2446 9589 o_tile=d->tile;
2447 9589 frate = d->frate;
2448 }
2449
2450 37112 tile=0; //init to 0 here, but set it later.
2451
2452 37112 scripttile = -1;
2453 37112 scriptflip = -1;
2454 37112 do_animation = 1;
2455 37112 immortal = false;
2456 37112 noSlide = false;
2457 37112 deathexstate = -1;
2458
2459 37112 hashero=false;
2460
2461 // If they forgot the invisibility flag, here's another failsafe:
2462
4/4
✓ Branch 0 taken 2415 times.
✓ Branch 1 taken 34697 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2321 times.
37112 if(o_tile==0 && family!=eeSPINTILE)
2463 2321 flags |= guy_invisible;
2464
2465 // step = d->step/100.0;
2466 // To preserve the odd step values for Keese & Gleeok heads. -L
2467
5/8
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4454 times.
✓ Branch 5 taken 32658 times.
✓ Branch 6 taken 4454 times.
✗ Branch 7 not taken.
37112 if(dstep==62.0) dstep+=0.5;
2468
5/8
✓ Branch 0 taken 32658 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32658 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 307 times.
✓ Branch 5 taken 32351 times.
✓ Branch 6 taken 307 times.
✗ Branch 7 not taken.
32658 else if(dstep==89) dstep-=1/9;
2469
2470
5/10
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 37112 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 37112 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 37112 times.
✗ Branch 9 not taken.
37112 step = zslongToFix(dstep*100);
2471
2472
2473 37112 item_set = d->item_set;
2474 37112 grumble = d->grumble;
2475
2476
2/2
✓ Branch 0 taken 27903 times.
✓ Branch 1 taken 9209 times.
37112 if(frate == 0)
2477 9209 frate = 256;
2478
2479 37112 leader = itemguy = dying = scored = false;
2480 37112 canfreeze = count_enemy = true;
2481 37112 mainguy = !(flags & guy_doesntcount);
2482
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 dir = zc_oldrand()&3;
2483
2484 //2.6 Enemy Editor Hit and TIle Sizes
2485
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2486 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
2487 // al_trace("Enemy txsz:%i\n", txsz);
2488
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
2489
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
2490
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
2491
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
2492
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
2493
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
2494 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
2495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
2496
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2497 {
2498 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
2499 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2500 }
2501
2502
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37112 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
2503
2504 37112 SIZEflags = d->SIZEflags;
2505
2506
8/10
✓ Branch 0 taken 37024 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 37024 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
37112 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
2507 1 wpn = 0;
2508
2509 //tile should never be 0 after init --Z (failsafe)
2510
4/6
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37112 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36064 times.
✓ Branch 5 taken 1048 times.
37112 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
2511
2512 //Moveflags; for gravity and pit interaction
2513 37112 moveflags = d->moveflags;
2514
3/4
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31774 times.
✓ Branch 3 taken 5338 times.
37112 if(!can_pitfall(false))
2515 {
2516 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
2517 5338 moveflags &= ~FLAG_CAN_PITFALL;
2518 5338 moveflags &= ~FLAG_CAN_WATERDROWN;
2519 5338 }
2520
2521
1/2
✓ Branch 0 taken 37112 times.
✗ Branch 1 not taken.
37112 shieldCanBlock = get_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG)?true:false;
2522 37112 }
2523
2524 //base clone constructor
2525
2526 enemy::enemy(enemy const & other, bool new_script_uid, bool clear_parent_script_UID):
2527 //Struct Element Type Purpose
2528 sprite(other),
2529 //x(other.x), //int32_t
2530 //y(other.y), //int32_t
2531 //id(other.id), //int32_t
2532 //clk(other.clk), //int32_t
2533 floor_y(other.floor_y), //int32_t
2534 fading(other.fading), //int32_t
2535 //misc(other.misc), //int32_t
2536 clk2(other.clk2), //int32_t
2537 clk3(other.clk3), //int32_t
2538 stunclk(other.stunclk), //int32_t
2539 hclk(other.hclk), //int32_t
2540 sclk(other.sclk), //int32_t
2541 superman(other.superman), //int32_t
2542 //grumble(other.grumble), //int32_t
2543 movestatus(other.movestatus), //int32_t
2544 posframe(other.posframe), //int32_t
2545 timer(other.timer), //int32_t
2546 ox(other.ox), //int32_t
2547 oy(other.oy), //int32_t
2548 //yofs(other.yofs), //int32_t
2549 did_armos(other.did_armos), //int32_t
2550 script_spawned(other.script_spawned), //int32_t
2551 d(other.d), //int32_t
2552 hp(other.hp), //int32_t
2553 starting_hp(other.starting_hp), //int32_t
2554 //flags(other.flags), //int32_t
2555
2556 flags2(other.flags2), //int32_t
2557 s_tile(other.s_tile), //int32_t
2558 family(other.family), //int32_t
2559 dcset(other.dcset), //int32_t
2560 //cs(other.cs), //int32_t
2561 anim(other.anim), //int32_t
2562 dp(other.dp), //int32_t
2563 wdp(other.wdp), //int32_t
2564 wpnsprite(other.wpnsprite), //int32_t
2565 rate(other.rate), //int32_t
2566 hrate(other.hrate), //int32_t
2567 dstep(other.dstep), //int32_t
2568
2569 homing(other.homing), //int32_t
2570 dmisc1(other.dmisc1), //int32_t
2571 dmisc2(other.dmisc2), //int32_t
2572 dmisc3(other.dmisc3), //int32_t
2573 dmisc4(other.dmisc4), //int32_t
2574 dmisc5(other.dmisc5), //int32_t
2575 dmisc6(other.dmisc6), //int32_t
2576 dmisc7(other.dmisc7), //int32_t
2577 dmisc8(other.dmisc8), //int32_t
2578 dmisc9(other.dmisc9), //int32_t
2579 dmisc10(other.dmisc10), //int32_t
2580 dmisc11(other.dmisc11), //int32_t
2581 dmisc12(other.dmisc12), //int32_t
2582 dmisc13(other.dmisc13), //int32_t
2583 dmisc14(other.dmisc14), //int32_t
2584 dmisc15(other.dmisc15), //int32_t
2585 dmisc16(other.dmisc16), //int32_t
2586 dmisc17(other.dmisc17), //int32_t
2587 dmisc18(other.dmisc18), //int32_t
2588 dmisc19(other.dmisc19), //int32_t
2589 dmisc20(other.dmisc20), //int32_t
2590 dmisc21(other.dmisc21), //int32_t
2591 dmisc22(other.dmisc22), //int32_t
2592 dmisc23(other.dmisc23), //int32_t
2593 dmisc24(other.dmisc24), //int32_t
2594 dmisc25(other.dmisc25), //int32_t
2595 dmisc26(other.dmisc26), //int32_t
2596 dmisc27(other.dmisc27), //int32_t
2597 dmisc28(other.dmisc28), //int32_t
2598 dmisc29(other.dmisc29), //int32_t
2599 dmisc30(other.dmisc30), //int32_t
2600 dmisc31(other.dmisc31), //int32_t
2601 dmisc32(other.dmisc32), //int32_t
2602 bgsfx(other.bgsfx), //int32_t
2603 hitsfx(other.hitsfx), //int32_t
2604 deadsfx(other.deadsfx), //int32_t
2605 bosspal(other.bosspal), //int32_t
2606 parent_script_UID(other.parent_script_UID), //int32_t
2607 frozentile(other.frozentile), //int32_t
2608 frozencset(other.frozencset), //int32_t
2609 frozenclock(other.frozenclock), //int32_t
2610 isCore(other.isCore), //int32_t
2611 parentCore(other.parentCore), //int32_t
2612 script_UID(other.script_UID), //int32_t
2613 firesfx(other.firesfx), //int32_t
2614 //script(other.script), //int32_t
2615 //waitdraw(other.waitdraw), //int32_t
2616 weaponscript(other.weaponscript), //int32_t
2617 stickclk(other.stickclk), //int32_t
2618 hitdir(other.hitdir), //int32_t
2619 submerged(other.submerged), //int32_t
2620 ffcactivated(other.ffcactivated), //word
2621
2622 dialogue_str(other.dialogue_str), //int32_t
2623 editorflags(other.editorflags), //int32_t
2624 //drawflags(other.drawflags), //int32_t
2625 o_tile(other.o_tile), //int32_t
2626 frate(other.frate), //int32_t
2627 //tile(other.tile), //int32_t
2628 //scripttile(other.scripttile), //int32_t
2629 //scriptflip(other.scriptflip), //int32_t
2630 //do_animation(other.do_animation), //int32_t
2631 immortal(other.immortal), //bool
2632 noSlide(other.noSlide), //bool
2633 deathexstate(other.deathexstate), //int32_t
2634 flags(other.flags), //int32_t
2635 step(other.step), //int32_t
2636
2637 item_set(other.item_set), //int32_t
2638 grumble(other.grumble), //int32_t
2639 leader(other.leader), //int32_t
2640 itemguy(other.itemguy), //int32_t
2641 dying(other.dying), //int32_t
2642 scored(other.scored), //int32_t
2643 //canfreeze(other.canfreeze), //int32_t
2644 count_enemy(other.count_enemy), //int32_t
2645 mainguy(other.mainguy), //int32_t
2646 //dir(other.dir), //int32_t
2647
2648 //txsz(other.txsz), //int32_t
2649 //tysz(other.tysz), //int32_t
2650 //hxsz(other.hxsz), //int32_t
2651 //hysz(other.hysz), //int32_t
2652 //hzsz(other.hzsz), //int32_t
2653 //hxofs(other.hxofs), //int32_t
2654 //hxofs(other.hxofs), //int32_t
2655 //xofs(other.xofs), //int32_t
2656 //yofs(other.yofs), //int32_t
2657 //hzofs(other.hzofs), //int32_t
2658 //zofs(other.zofs), //int32_t
2659
2660 wpn(other.wpn), //int32_t
2661 SIZEflags(other.SIZEflags), //int32_t
2662 hashero(other.hashero)
2663
2664 {
2665
2666 //arrays
2667
2668 if(other.scrmem)
2669 {
2670 alloc_scriptmem();
2671 memcpy(scrmem->stack, other.scrmem->stack, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
2672
2673 scrmem->scriptData = other.scrmem->scriptData;
2674 }
2675 else scrmem = NULL;
2676 //memset((refInfo)scriptData, 0xFFFF, sizeof(refInfo));
2677 //memset((refInfo)scriptData, other.scriptData, sizeof(refInfo));
2678
2679 for(int32_t i=0; i<edefLAST255; i++)
2680 defense[i]=other.defense[i];
2681 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = other.frozenmisc[q];
2682 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = other.hitby[q];
2683
2684 if(new_script_uid)
2685 {
2686 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
2687 }
2688 if(clear_parent_script_UID)
2689 {
2690 parent_script_UID = 0;
2691 }
2692 for ( int32_t q = 0; q < 32; q++ ) movement[q] = other.movement[q];
2693 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = other.new_weapon[q];
2694
2695 for ( int32_t q = 0; q < 8; q++ )
2696 {
2697 initD[q] = other.initD[q];
2698 weap_initiald[q] = other.weap_initiald[q];
2699 }
2700 for ( int32_t q = 0; q < 2; q++ )
2701 {
2702 initA[q] = other.initA[q];
2703 weap_initiala[q] = other.weap_initiala[q];
2704 }
2705 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
2706 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
2707 // al_trace("Enemy txsz:%i\n", txsz);
2708 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
2709 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
2710 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
2711 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
2712 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
2713 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
2714 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
2715 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
2716 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
2717 {
2718 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
2719 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
2720 }
2721
2722 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
2723
2724
2725
2726
2727 }
2728
2729
2730 489 int32_t enemy::getScriptUID() { return script_UID; }
2731 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
2732 37093 enemy::~enemy()
2733 37093 {
2734
2/4
✓ Branch 0 taken 37093 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37093 times.
✗ Branch 3 not taken.
37093 FFCore.deallocateAllArrays(SCRIPT_NPC, getUID());
2735
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 37090 times.
37093 if(hashero)
2736 {
2737
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 Hero.setEaten(0);
2738 3 hashero=false;
2739 3 }
2740 37093 }
2741
2742
2743 bool enemy::is_move_paused()
2744 {
2745 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
2746 }
2747
2748 11304 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
2749 {
2750 11304 int32_t yg = (special==spw_floater)?8:0;
2751 11304 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
2752 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
2753
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(input_x == -1000)
2754 input_x = dx;
2755
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(input_y == -1000)
2756 input_y = dy;
2757
2758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
22608 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
2759
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11304 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11304 times.
11304 && (input_x<16-nb || input_y<zc_max(16-yg-nb,0)
2760
2/4
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
11304 || input_x>=240+nb-hxsz || input_y>=160+nb-hysz))
2761 return true;
2762
2763
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
11304 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
2764 {
2765 if(ispitfall(dx,dy))
2766 return true;
2767 }
2768
2769 11304 bool flying = false;
2770 11304 bool cansolid = false;
2771
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if(moveflags & FLAG_IGNORE_SOLIDITY)
2772 cansolid = true;
2773
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11304 switch(special)
2774 {
2775 case spw_clipbottomright:
2776 if(dy>=128 || dx>=208) return true;
2777 break;
2778 case spw_clipright:
2779 break; //if(input_x>=208) return true; break;
2780
2781 case spw_wizzrobe: // fall through
2782 case spw_floater: // Special case for fliers and wizzrobes - hack!
2783 {
2784 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
2785 {
2786 if(dy < 32-yg || dy >= 144) return true;
2787 if(dx < 32 || dx >= 224) return true;
2788 }
2789 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
2790 return true;
2791 cansolid = true;
2792 flying = true;
2793 }
2794 }
2795
2796 11304 dx &= ~7;
2797 11304 dy &= ~7;
2798
2799
3/6
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
11304 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
2800
2801
4/8
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11304 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11304 times.
11304 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
2802 return false;
2803 //_walkflag code
2804 mapscr *s1, *s2;
2805 11304 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
2806 11304 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
2807
2808 11304 int32_t cpos=(dx>>4)+(dy&0xF0);
2809
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✓ Branch 2 taken 8964 times.
✓ Branch 3 taken 2340 times.
11304 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
2810 11304 newcombo const& c = combobuf[ci];
2811 11304 newcombo const& c1 = combobuf[ci1];
2812 11304 newcombo const& c2 = combobuf[ci2];
2813
2814 11304 int32_t b=1;
2815
2/2
✓ Branch 0 taken 5447 times.
✓ Branch 1 taken 5857 times.
11304 if(dx&8) b<<=2;
2816
2/2
✓ Branch 0 taken 5885 times.
✓ Branch 1 taken 5419 times.
11304 if(dy&8) b<<=1;
2817
2818 #define iwtr(cmb, x, y, shallow) \
2819 (shallow \
2820 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
2821 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
2822 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
2823 11304 bool wtr = iwtr(ci, dx, dy, false);
2824
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 bool shwtr = iwtr(ci, dx, dy, true);
2825 11304 bool pit = ispitfall(dx,dy);
2826
2827
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
11304 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
2828
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11304 times.
11304 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
2829 11304 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
2830 11304 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
2831 11304 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
2832
2833 11304 int32_t cwalkflag = c.walk & 0xF;
2834
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11304 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11304 if (c.type == cBRIDGE && get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
2835
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 if (s1)
2836 {
2837 if (c1.type == cBRIDGE)
2838 {
2839 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2840 {
2841 int efflag = (c1.walk & 0xF0)>>4;
2842 int newsolid = (c1.walk & 0xF);
2843 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2844 }
2845 else cwalkflag &= c1.walk;
2846 }
2847 else cwalkflag |= c1.walk & 0xF;
2848 }
2849
2/2
✓ Branch 0 taken 2340 times.
✓ Branch 1 taken 8964 times.
11304 if (s2)
2850 {
2851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8964 times.
8964 if (c2.type == cBRIDGE)
2852 {
2853 if (!get_bit(quest_rules, qr_OLD_BRIDGE_COMBOS))
2854 {
2855 int efflag = (c2.walk & 0xF0)>>4;
2856 int newsolid = (c2.walk & 0xF);
2857 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
2858 }
2859 else cwalkflag &= c2.walk;
2860 }
2861 8964 else cwalkflag |= c2.walk & 0xF;
2862 8964 }
2863 11304 bool solid = cwalkflag & b;
2864
3/4
✓ Branch 0 taken 1437 times.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1437 times.
11304 if (solid && !cansolid) return true;
2865
3/6
✓ Branch 0 taken 9867 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9867 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9867 times.
9867 if(needwtr || needshwtr || needpit)
2866 {
2867 bool ret = true;
2868 if (needwtr && wtr) ret = false;
2869 else if (needshwtr && shwtr) ret = false;
2870 else if (needpit && pit) ret = false;
2871 return ret;
2872 }
2873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9867 else if(wtr && !canwtr)
2874 return true;
2875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9867 else if(pit && !canpit)
2876 return true;
2877
2878 9867 return false;
2879 11304 }
2880
2881 4726 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
2882 {
2883
3/4
✓ Branch 0 taken 3330 times.
✓ Branch 1 taken 1396 times.
✓ Branch 2 taken 3330 times.
✗ Branch 3 not taken.
4726 if(!(dx || dy)) return true;
2884 4726 zfix bx = x+hxofs, by = y+hyofs; //left/top
2885 4726 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2886
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4726 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4726 if(!ign_sv && dy < 0) //check gravity
2887 {
2888 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
2889 return false;
2890 }
2891
2892
3/4
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 3330 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1396 times.
4726 if(dx && !dy)
2893 {
2894
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 619 times.
1396 if(dx < 0)
2895 {
2896
2/4
✓ Branch 0 taken 777 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 777 times.
777 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
2897 777 int32_t tx = (bx+dx).getFloor();
2898
2/2
✓ Branch 0 taken 1554 times.
✓ Branch 1 taken 777 times.
2331 for(zfix ty = 0; by+ty < ry; ty += 8)
2899 {
2900
1/2
✓ Branch 0 taken 1554 times.
✗ Branch 1 not taken.
1554 if(scr_walkflag(tx, by+ty, special, left, bx, by, kb))
2901 return false;
2902 1554 }
2903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 777 times.
777 if(scr_walkflag(tx, ry, special, left, bx, by, kb))
2904 return false;
2905 777 }
2906 else
2907 {
2908 619 int32_t tx = (rx+dx).getCeil();
2909
2/2
✓ Branch 0 taken 1238 times.
✓ Branch 1 taken 619 times.
1857 for(zfix ty = 0; by+ty < ry; ty += 8)
2910 {
2911
1/2
✓ Branch 0 taken 1238 times.
✗ Branch 1 not taken.
1238 if(scr_walkflag(tx, by+ty, special, right, bx, by, kb))
2912 return false;
2913 1238 }
2914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 619 times.
619 if(scr_walkflag(tx, ry, special, right, bx, by, kb))
2915 return false;
2916 }
2917 1396 }
2918
2/4
✓ Branch 0 taken 3330 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3330 times.
3330 else if(dy && !dx)
2919 {
2920
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 1535 times.
3330 if(dy < 0)
2921 {
2922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1795 times.
1795 special = (special==spw_clipbottomright)?spw_none:special;
2923 1795 int32_t ty = (by+dy).getFloor();
2924
2/2
✓ Branch 0 taken 3590 times.
✓ Branch 1 taken 1795 times.
5385 for(zfix tx = 0; bx+tx < rx; tx += 8)
2925 {
2926
1/2
✓ Branch 0 taken 3590 times.
✗ Branch 1 not taken.
3590 if(scr_walkflag(bx+tx, ty, special, up, bx, by, kb))
2927 return false;
2928 3590 }
2929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1795 times.
1795 if(scr_walkflag(rx, ty, special, up, bx, by, kb))
2930 return false;
2931 1795 }
2932 else
2933 {
2934 1535 int32_t ty = (ry+dy).getCeil();
2935
2/2
✓ Branch 0 taken 1633 times.
✓ Branch 1 taken 98 times.
1731 for(zfix tx = 0; bx+tx < rx; tx += 8)
2936 {
2937
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 1437 times.
1633 if(scr_walkflag(bx+tx, ty, special, down, bx, by, kb))
2938 1437 return false;
2939 196 }
2940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(scr_walkflag(rx, ty, special, down, bx, by, kb))
2941 return false;
2942 }
2943 1893 }
2944 else
2945 {
2946 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
2947 }
2948 3289 return true;
2949 4726 }
2950
2951 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
2952 {
2953 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
2954 zfix rx = bx+hxsz-1, ry = by+hysz-1; //right/bottom
2955
2956 for(zfix ty = 0; by+ty < ry; ty += 8)
2957 {
2958 for(zfix tx = 0; bx+tx < rx; tx += 8)
2959 {
2960 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
2961 return false;
2962 }
2963 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
2964 return false;
2965 }
2966 for(zfix tx = 0; bx+tx < rx; tx += 8)
2967 {
2968 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
2969 return false;
2970 }
2971 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
2972 return false;
2973 return true;
2974 }
2975
2976 3427 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
2977 {
2978 3427 bool ret = true;
2979
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 3427 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3427 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
2980 dy = 0;
2981
4/4
✓ Branch 0 taken 3547 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 3427 times.
✓ Branch 3 taken 179 times.
3606 while(abs(dx) > 8 || abs(dy) > 8)
2982 {
2983
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 139 times.
179 if(abs(dx) > abs(dy))
2984 {
2985 40 int32_t tdx = dx.sign() * 8;
2986
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(movexy(tdx, 0, special, kb, ign_sv))
2987 40 dx -= tdx;
2988 else
2989 {
2990 dx = tdx;
2991 ret = false;
2992 }
2993 40 }
2994 else
2995 {
2996 139 int32_t tdy = dy.sign() * 8;
2997
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 136 times.
139 if(movexy(0, tdy, special, kb, ign_sv))
2998 3 dy -= tdy;
2999 else
3000 {
3001 136 dy = tdy;
3002 136 ret = false;
3003 }
3004 }
3005 }
3006
2/2
✓ Branch 0 taken 2031 times.
✓ Branch 1 taken 1396 times.
3427 if(dx)
3007 {
3008
1/2
✓ Branch 0 taken 1396 times.
✗ Branch 1 not taken.
1396 if(scr_canmove(dx, 0, special, kb, ign_sv))
3009 1396 x += dx;
3010 else
3011 {
3012 ret = false;
3013 int32_t xsign = dx.sign();
3014 while(scr_canmove(xsign, 0, special, kb, ign_sv))
3015 {
3016 x += xsign;
3017 dx -= xsign;
3018 }
3019 if(scr_canmove(dx.decsign(), 0, special, kb, ign_sv)) //can move 0.0001 to 0.9999 px in this direction
3020 {
3021 if(dx > 0)
3022 x.doCeil();
3023 else x.doFloor();
3024 }
3025 }
3026 1396 }
3027
2/2
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 2372 times.
3427 if(dy)
3028 {
3029
2/2
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 479 times.
2372 if(scr_canmove(0, dy, special, kb, ign_sv))
3030 1893 y += dy;
3031 else
3032 {
3033 479 ret = false;
3034 479 int32_t ysign = dy.sign();
3035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 479 times.
479 while(scr_canmove(0, ysign, special, kb, ign_sv))
3036 {
3037 y += ysign;
3038 dy -= ysign;
3039 }
3040
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(scr_canmove(0, dy.decsign(), special, kb, ign_sv)) //can move 0.0001 to 0.9999 px in this direction
3041 {
3042 if(dy > 0)
3043 y.doCeil();
3044 else y.doFloor();
3045 }
3046 }
3047 2372 }
3048 3427 return ret;
3049 }
3050
3051 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3052 {
3053 zfix diagrate = zslongToFix(7071);
3054 switch(NORMAL_DIR(dir))
3055 {
3056 case up:
3057 return movexy(0, -px, special, kb);
3058 case down:
3059 return movexy(0, px, special, kb);
3060 case left:
3061 return movexy(-px, 0, special, kb);
3062 case right:
3063 return movexy(px, 0, special, kb);
3064 case r_up:
3065 return movexy(px*diagrate, -px*diagrate, special, kb);
3066 case r_down:
3067 return movexy(px*diagrate, px*diagrate, special, kb);
3068 case l_up:
3069 return movexy(-px*diagrate, -px*diagrate, special, kb);
3070 case l_down:
3071 return movexy(-px*diagrate, px*diagrate, special, kb);
3072 }
3073 return false;
3074 }
3075
3076 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3077 {
3078 double v = degrees.getFloat() * PI / 180.0;
3079 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
3080 return movexy(dx, dy, special, kb);
3081 }
3082
3083 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
3084 {
3085 zfix tx = x, ty = y;
3086 bool ret = movexy(dx, dy, special, kb);
3087 x = tx;
3088 y = ty;
3089 return ret;
3090 }
3091 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
3092 {
3093 zfix tx = x, ty = y;
3094 bool ret = moveDir(dir, px, special, kb);
3095 x = tx;
3096 y = ty;
3097 return ret;
3098 }
3099 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
3100 {
3101 zfix tx = x, ty = y;
3102 bool ret = moveAtAngle(degrees, px, special, kb);
3103 x = tx;
3104 y = ty;
3105 return ret;
3106 }
3107
3108 // Handle pitfalls
3109 15718990 bool enemy::do_falling(int32_t index)
3110 {
3111
2/2
✓ Branch 0 taken 15718848 times.
✓ Branch 1 taken 142 times.
15718990 if(fallclk > 0)
3112 {
3113
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
3114
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
3115 {
3116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
3117 ++fallclk; //force another frame of falling.... forever.
3118
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
3119 {
3120
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
3121 never_return(index);
3122
3123
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
3124 kill_em_all();
3125
3126 //leave_item(); //Don't drop items in pits!
3127 2 stop_bgsfx(index);
3128 2 return true;
3129 }
3130 else
3131 {
3132 2 try_death(true); //Force death
3133 2 ++fallclk; //force another frame of falling
3134 }
3135 2 }
3136
3137 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
3138 140 cs = spr.csets & 0xF;
3139
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
3140
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
3141 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
3142
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
3143 140 }
3144 15718988 return false;
3145 15718990 }
3146
3147 // Handle drowning in water
3148 15718848 bool enemy::do_drowning(int32_t index)
3149 {
3150
1/2
✓ Branch 0 taken 15718848 times.
✗ Branch 1 not taken.
15718848 if(drownclk > 0)
3151 {
3152 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
3153 //!TODO: Drown SFX
3154 if(!--drownclk)
3155 {
3156 if(immortal) //Keep alive forever
3157 ++drownclk; //force another frame of falling.... forever.
3158 else if(dying) //Give 1 frame for script revival
3159 {
3160 if(flags&guy_neverret)
3161 never_return(index);
3162
3163 if(leader)
3164 kill_em_all();
3165
3166 //leave_item(); //Don't drop items in pits!
3167 stop_bgsfx(index);
3168 return true;
3169 }
3170 else
3171 {
3172 try_death(true); //Force death
3173 ++drownclk; //force another frame of falling
3174 }
3175 }
3176
3177 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
3178 {
3179 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
3180 cs = spr.csets & 0xF;
3181 int32_t fr = spr.frames ? spr.frames : 1;
3182 int32_t spd = spr.speed ? spr.speed : 1;
3183 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3184 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3185 }
3186 else
3187 {
3188 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
3189 cs = spr.csets & 0xF;
3190 int32_t fr = spr.frames ? spr.frames : 1;
3191 int32_t spd = spr.speed ? spr.speed : 1;
3192 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
3193 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
3194 }
3195 }
3196 15718848 return false;
3197 15718848 }
3198
3199 // Supplemental animation code that all derived classes should call
3200 // as a return value for animate().
3201 // Handles the death animation and returns true when enemy is finished.
3202 16017063 bool enemy::Dead(int32_t index)
3203 {
3204
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 16015234 times.
16017063 if(immortal)
3205 {
3206 1829 dying = false;
3207 1829 return false;
3208 }
3209
2/2
✓ Branch 0 taken 322055 times.
✓ Branch 1 taken 15693179 times.
16015234 if(dying)
3210 {
3211
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 322054 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
322055 if(deathexstate > -1 && deathexstate < 32)
3212 {
3213 1 setxmapflag(1<<deathexstate);
3214 1 deathexstate = -1;
3215 1 }
3216 322055 --clk2;
3217
3218
4/4
✓ Branch 0 taken 317360 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 16217 times.
✓ Branch 3 taken 501 times.
322055 if((get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
3219
2/2
✓ Branch 0 taken 16718 times.
✓ Branch 1 taken 300642 times.
317360 && hp>-1000) // not killed by ringleader
3220 16217 death_sfx();
3221
3222
2/2
✓ Branch 0 taken 305113 times.
✓ Branch 1 taken 16942 times.
322055 if(clk2==0)
3223 {
3224
2/2
✓ Branch 0 taken 16602 times.
✓ Branch 1 taken 340 times.
16942 if(flags&guy_neverret)
3225 340 never_return(index);
3226
3227
2/2
✓ Branch 0 taken 16889 times.
✓ Branch 1 taken 53 times.
16942 if(leader)
3228 53 kill_em_all();
3229
3230 16942 leave_item();
3231 16942 }
3232
3233 322055 stop_bgsfx(index);
3234 322055 return (clk2==0);
3235 }
3236
3237 15693179 return false;
3238 16017063 }
3239
3240 // Basic animation code that all derived classes should call.
3241 // The one with an index is the one that is called by
3242 // the guys sprite list; index is the enemy's index in the list.
3243 16369140 bool enemy::animate(int32_t index)
3244 {
3245
2/2
✓ Branch 0 taken 1403665 times.
✓ Branch 1 taken 14965475 times.
16369140 if(sclk <= 0) hitdir = -1;
3246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15414384 times.
16369140 if(switch_hooked)
3247 {
3248 if(get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT))
3249 {
3250 //Run its script
3251 if (run_script(MODE_NORMAL)==RUNSCRIPT_SELFDELETE)
3252 {
3253 return 0; //Avoid NULLPO if this object deleted itself
3254 }
3255 }
3256 return false;
3257 }
3258
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 15414382 times.
15414384 if(do_falling(index)) return true;
3259
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 15414242 times.
15414382 else if(fallclk)
3260 {
3261 //clks
3262
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
3263 60 --hclk;
3264
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
3265 --stunclk;
3266
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
3267 --frozenclock;
3268
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
3269 {
3270 Hero.setX(x);
3271 Hero.setY(y);
3272 Hero.fallCombo = fallCombo;
3273 Hero.fallclk = fallclk;
3274 hashero = false; //Let Hero go if falling
3275 }
3276 140 run_script(MODE_NORMAL);
3277 140 return false;
3278 }
3279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15414242 times.
15414242 if(do_drowning(index)) return true;
3280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15414242 times.
15414242 else if(drownclk)
3281 {
3282 //clks
3283 if(hclk>0)
3284 --hclk;
3285 if(stunclk>0)
3286 --stunclk;
3287 if ( frozenclock > 0 )
3288 --frozenclock;
3289 if(hashero)
3290 {
3291 Hero.setX(x);
3292 Hero.setY(y);
3293 Hero.drownclk = drownclk;
3294 hashero = false; //Let Hero go if falling
3295 }
3296 run_script(MODE_NORMAL);
3297 return false;
3298 }
3299 15414242 int32_t nx = real_x(x);
3300 15414242 int32_t ny = real_y(y);
3301
3302
4/4
✓ Branch 0 taken 11485436 times.
✓ Branch 1 taken 3928806 times.
✓ Branch 2 taken 2570852 times.
✓ Branch 3 taken 12256256 times.
15414242 if(ox!=nx || oy!=ny)
3303 {
3304 6499658 posframe=(posframe+1)%(get_bit(quest_rules,qr_NEWENEMYTILES)?4:2);
3305 6499658 }
3306
3307 18755914 ox = nx;
3308 18755914 oy = ny;
3309
3310 // Maybe they fell off the bottom in sideview, or were moved by a script.
3311
3312 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
3313
2/2
✓ Branch 0 taken 3038895 times.
✓ Branch 1 taken 15717019 times.
18755914 if ( immortal )
3314 {
3315 //skip, as it can go out of bounds, from immortality
3316 3038895 }
3317
2/6
✓ Branch 0 taken 15717019 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15717019 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15717019 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_bit(quest_rules, qr_OUTOFBOUNDSENEMIES)) != (editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
3318 {
3319 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
3320 }
3321
9/10
✓ Branch 0 taken 15296626 times.
✓ Branch 1 taken 420393 times.
✓ Branch 2 taken 15716690 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 15716645 times.
✓ Branch 5 taken 45 times.
✓ Branch 6 taken 15716645 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 15716609 times.
15717019 else if ( (OUTOFBOUNDS) )
3322 {
3323 410 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
3324 410 }
3325 //fall down
3326
6/6
✓ Branch 0 taken 9064566 times.
✓ Branch 1 taken 9478468 times.
✓ Branch 2 taken 6495320 times.
✓ Branch 3 taken 12047714 times.
✓ Branch 4 taken 293418 times.
✓ Branch 5 taken 6201902 times.
18755914 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
3327 {
3328
2/2
✓ Branch 0 taken 327574 times.
✓ Branch 1 taken 5874328 times.
6201902 if(isSideViewGravity())
3329 {
3330
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 24000 times.
327574 if(get_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE))
3331 {
3332
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
3333 {
3334 127235 bool willHitSVPlatform = false;
3335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hxsz:16;
3336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hysz:16;
3337
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
3338 {
3339
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
3340 {
3341 willHitSVPlatform = true;
3342 break;
3343 }
3344 127235 }
3345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
3346 {
3347 y+=fall/100;
3348 //y-=int32_t(y)%16; //Fix to top of SV Ladder
3349 do_fix(y, 16); //Fix to top of SV Ladder
3350 fall = 0;
3351 }
3352 else
3353 {
3354 127235 y+=fall/100;
3355
2/2
✓ Branch 0 taken 17808 times.
✓ Branch 1 taken 109427 times.
127235 if(fall <= (int32_t)zinit.terminalv)
3356 109427 fall += (zinit.gravity2/100);
3357 }
3358 127235 }
3359 else
3360 {
3361
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
3362 {
3363 //y-=(int32_t)y%8; // Fix position
3364 267 do_fix(y, 8); //Fix position
3365 267 }
3366
3367 176339 fall = 0;
3368 }
3369 303574 }
3370 else
3371 {
3372
2/2
✓ Branch 0 taken 22585 times.
✓ Branch 1 taken 1415 times.
24000 if(isOnSideviewPlatform())
3373 22585 fall = 0;
3374 else
3375 {
3376 1415 zfix fall_amnt = fall/100;
3377 1415 bool hit = false;
3378
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 1819 times.
3201 while(fall_amnt >= 1)
3379 {
3380 1819 --fall_amnt;
3381 1819 ++y;
3382
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 33 times.
1819 if(isOnSideviewPlatform())
3383 {
3384 33 y = y.getInt();
3385 33 fall_amnt = 0;
3386 33 hit = true;
3387 33 break;
3388 }
3389 }
3390
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 1302 times.
1415 if(fall_amnt > 0)
3391 1302 y += fall_amnt;
3392
1/2
✓ Branch 0 taken 1415 times.
✗ Branch 1 not taken.
1415 if(fall_amnt < 0)
3393 {
3394 if(!movexy(0,fall_amnt,spw_none))
3395 hit = true;
3396 }
3397
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1382 times.
1415 if(hit)
3398 33 fall = 0;
3399
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 1105 times.
1382 else if(fall <= (int32_t)zinit.terminalv)
3400 1105 fall += (zinit.gravity2/100);
3401 }
3402 }
3403 327574 }
3404 else
3405 {
3406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5874328 times.
5874328 if (!(moveflags & FLAG_NO_FAKE_Z))
3407 {
3408
2/2
✓ Branch 0 taken 2982330 times.
✓ Branch 1 taken 2891998 times.
5874328 if(fakefall!=0)
3409 2891998 fakez-=(fakefall/100);
3410
3411
2/2
✓ Branch 0 taken 2891998 times.
✓ Branch 1 taken 2982330 times.
5874328 if(fakez<0)
3412 2891998 fakez = fakefall = 0;
3413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982330 times.
2982330 else if(fakefall <= (int32_t)zinit.terminalv)
3414 2982330 fakefall += (zinit.gravity2/100);
3415
3416
5/6
✓ Branch 0 taken 5874328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2982330 times.
✓ Branch 3 taken 2891998 times.
✓ Branch 4 taken 2899012 times.
✓ Branch 5 taken 83318 times.
5874328 if (fakez<=0 && fakefall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
3417 5874328 }
3418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5874328 times.
5874328 if (!(moveflags & FLAG_NO_REAL_Z))
3419 {
3420
2/2
✓ Branch 0 taken 2989696 times.
✓ Branch 1 taken 2884632 times.
5874328 if(fall!=0)
3421 2884632 z-=(fall/100);
3422
3423
2/2
✓ Branch 0 taken 2878808 times.
✓ Branch 1 taken 2995520 times.
5874328 if(z<0)
3424 2878808 z = fall = 0;
3425
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 2990876 times.
2995520 else if(fall <= (int32_t)zinit.terminalv)
3426 2990876 fall += (zinit.gravity2/100);
3427
3428
6/6
✓ Branch 0 taken 5868407 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 2989599 times.
✓ Branch 3 taken 2878808 times.
✓ Branch 4 taken 2906281 times.
✓ Branch 5 taken 83318 times.
5874328 if (z<=0 && fall > 0 && !get_bit(quest_rules, qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
3429 5874328 }
3430
3431 }
3432 6201902 }
3433
4/4
✓ Branch 0 taken 15298455 times.
✓ Branch 1 taken 3244579 times.
✓ Branch 2 taken 7009964 times.
✓ Branch 3 taken 16341529 times.
18543034 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
3434 {
3435
8/10
✓ Branch 0 taken 5454951 times.
✓ Branch 1 taken 10886578 times.
✓ Branch 2 taken 5447966 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 5447966 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5454951 times.
✓ Branch 8 taken 5447966 times.
✓ Branch 9 taken 5447966 times.
16341529 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3436 {
3437 5447966 fallCombo = check_pits();
3438 5447966 }
3439 27237461 }
3440
3/4
✓ Branch 0 taken 15298455 times.
✓ Branch 1 taken 420393 times.
✓ Branch 2 taken 15298455 times.
✗ Branch 3 not taken.
15718848 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
3441 {
3442 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
3443 {
3444 drownCombo = check_water();
3445 }
3446 }
3447
3448 15718848 runKnockback(); //scripted knockback handling
3449
3450 // clk is incremented here
3451
2/2
✓ Branch 0 taken 14918060 times.
✓ Branch 1 taken 800788 times.
15718848 if(++clk >= frate)
3452 800788 clk=0;
3453
3454 // hit and death handling
3455
2/2
✓ Branch 0 taken 15154871 times.
✓ Branch 1 taken 563977 times.
15718848 if(hclk>0)
3456 563977 --hclk;
3457
3458
2/2
✓ Branch 0 taken 15420037 times.
✓ Branch 1 taken 298811 times.
15718848 if(stunclk>0)
3459 298811 --stunclk;
3460
1/2
✓ Branch 0 taken 15718848 times.
✗ Branch 1 not taken.
15718848 if ( frozenclock > 0 )
3461 --frozenclock;
3462
3463
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 15711846 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
15718848 if(ceiling && z <= 0 && fakez <= 0)
3464 55 ceiling = false;
3465
3466 15718848 try_death();
3467
3468 15718848 scored=false;
3469
3470 15718848 ++c_clk;
3471
3472 //Run its script
3473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15718848 times.
15718848 if (run_script(MODE_NORMAL)==RUNSCRIPT_SELFDELETE)
3474 {
3475 return 0; //Avoid NULLPO if this object deleted itself
3476 }
3477
3478 // returns true when enemy is defeated
3479 15718848 return Dead(index);
3480 15718990 }
3481
3482 16053272 bool enemy::setSolid(bool set)
3483 {
3484
1/2
✓ Branch 0 taken 16053272 times.
✗ Branch 1 not taken.
16053272 bool actual = set && !isSubmerged();
3485 16053272 bool ret = solid_object::setSolid(actual);
3486 16053272 solid = set;
3487 16053272 return ret;
3488 }
3489 void enemy::doContactDamage(int32_t hdir)
3490 {
3491 Hero.hithero(guys.find(this), hdir);
3492 }
3493
3494 90488 void enemy::solid_push(solid_object *obj)
3495 {
3496
1/2
✓ Branch 0 taken 90488 times.
✗ Branch 1 not taken.
90488 if(obj == this) return; //can't push self
3497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90488 times.
90488 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
3498 90488 zfix dx, dy;
3499 90488 int32_t hdir = -1;
3500 90488 solid_push_int(obj,dx,dy,hdir);
3501
3502
4/4
✓ Branch 0 taken 89132 times.
✓ Branch 1 taken 1356 times.
✓ Branch 2 taken 87240 times.
✓ Branch 3 taken 1892 times.
90488 if(!dx && !dy) return;
3503
3504 3248 bool t = obj->getTempNonsolid();
3505 3248 obj->setTempNonsolid(true);
3506
3507 3248 int32_t ydir = dy > 0 ? down : up;
3508 3248 int32_t xdir = dx > 0 ? right : left;
3509
3510 3248 auto special = isflier(id) ? spw_floater : spw_none;
3511
2/2
✓ Branch 0 taken 2905 times.
✓ Branch 1 taken 343 times.
3248 if(!movexy(dx,dy,special,true,true))
3512 {
3513 //Crushed?
3514 343 }
3515
3516 3248 obj->setTempNonsolid(t);
3517 90488 }
3518 90488 bool enemy::is_unpushable() const
3519 {
3520 90488 return isSubmerged();
3521 }
3522 90488 bool enemy::sideview_mode() const
3523 {
3524
3/4
✓ Branch 0 taken 24300 times.
✓ Branch 1 taken 66188 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24300 times.
90488 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
3525 }
3526
3527 2252 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
3528 {
3529 2252 int32_t yg = (special==spw_floater)?8:0;
3530 2252 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3531
3532
8/10
✓ Branch 0 taken 1702 times.
✓ Branch 1 taken 550 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 550 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 550 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1704 times.
✓ Branch 9 taken 2254 times.
2252 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3533 3406 return true;
3534
3535 2254 bool isInDungeon = isdungeon();
3536
3/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 2139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 115 times.
2254 if(isInDungeon || special==spw_wizzrobe)
3537 {
3538
7/8
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1707 times.
✓ Branch 2 taken 427 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 433 times.
✓ Branch 5 taken 1279 times.
✓ Branch 6 taken 433 times.
✗ Branch 7 not taken.
2139 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
3539 860 return true;
3540
3541
7/8
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 427 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 427 times.
✓ Branch 5 taken 427 times.
✓ Branch 6 taken 427 times.
✗ Branch 7 not taken.
1279 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
3542
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
854 if(special!=spw_door) // walk in door way
3543 return true;
3544 427 }
3545
3546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
542 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
3547 {
3548 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3549 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3550 return true;
3551 }
3552
3553
1/4
✓ Branch 0 taken 542 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
542 switch(special)
3554 {
3555 case spw_clipbottomright:
3556 if(dy>=128 || dx>=208) return true;
3557 break;
3558 case spw_clipright:
3559 break; //if(x>=208) return true; break;
3560
3561 case spw_wizzrobe: // fall through
3562 case spw_floater: // Special case for fliers and wizzrobes - hack!
3563 {
3564
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 427 times.
542 if(isInDungeon)
3565 {
3566
2/4
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
427 if(dy < 32-yg || dy >= 144) return true;
3567
2/4
✓ Branch 0 taken 427 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 427 times.
427 if(dx < 32 || dx >= 224) return true;
3568 427 }
3569 542 return false;
3570 }
3571 }
3572
3573 dx&=(special==spw_halfstep)?(~7):(~15);
3574 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3575
3576 if(special==spw_water)
3577 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3578
3579 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3580 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
3581 550 }
3582
3583 607 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
3584 {
3585 607 bool kb = false;
3586 607 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3587
3588
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 499 times.
✓ Branch 3 taken 108 times.
✓ Branch 4 taken 607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 607 times.
607 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
3589 return true;
3590
3591
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 481 times.
607 if(isdungeon())
3592 {
3593
2/4
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 481 times.
481 if((dy<32) || (dy>=144))
3594 return true;
3595
3596
2/4
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 481 times.
481 if((dx<32) || (dx>=224))
3597 return true;
3598 481 }
3599
3600
2/4
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 607 times.
607 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
3601 {
3602
2/4
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 607 times.
1214 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3603
2/4
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 607 times.
✗ Branch 3 not taken.
607 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3604 return true;
3605 607 }
3606
3607
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3608 {
3609
3/4
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 595 times.
✗ Branch 3 not taken.
1202 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 595 times.
595 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3611 }
3612 else
3613 {
3614 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3615 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3616 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3617 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3618 }
3619 607 }
3620
3621 15992435 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
3622 {
3623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15992435 times.
15992435 if(moveflags & FLAG_USE_NEW_MOVEMENT)
3624 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
3625 15992435 int32_t yg = (special==spw_floater)?8:0;
3626 15992435 int32_t nb = get_bit(quest_rules, qr_NOBORDER) ? 16 : 0;
3627
2/2
✓ Branch 0 taken 1502329 times.
✓ Branch 1 taken 14490106 times.
15992435 switch(dir)
3628 {
3629 case l_down:
3630 case r_down:
3631 case down:
3632 case 11: //r_down
3633 case 12: //down
3634 case 13: //l_down
3635 {
3636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1502329 times.
1502329 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3637 {
3638
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1502329 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1502329 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
3639 {
3640 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3641 dy += zc_max(hysz-16,0);
3642 }
3643 1502329 }
3644 1502329 break;
3645 }
3646 }
3647
2/2
✓ Branch 0 taken 1512864 times.
✓ Branch 1 taken 14479571 times.
15992435 switch(dir)
3648 {
3649 case r_up:
3650 case r_down:
3651 case right:
3652 case 9: //r_up
3653 case 10: //right
3654 case 11: //r_down
3655 {
3656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1512864 times.
1512864 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
3657 {
3658
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1512864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1512864 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
3659 {
3660 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
3661 dx += zc_max(hxsz-16,0);
3662 }
3663 1512864 }
3664 1512864 break;
3665 }
3666 }
3667 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
3668
3669
10/10
✓ Branch 0 taken 11964608 times.
✓ Branch 1 taken 4027827 times.
✓ Branch 2 taken 1106864 times.
✓ Branch 3 taken 2920963 times.
✓ Branch 4 taken 4021024 times.
✓ Branch 5 taken 6803 times.
✓ Branch 6 taken 4015201 times.
✓ Branch 7 taken 5823 times.
✓ Branch 8 taken 11977445 times.
✓ Branch 9 taken 15992646 times.
15992435 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
3670 23954679 return true;
3671
3672 15992646 bool isInDungeon = isdungeon();
3673
4/4
✓ Branch 0 taken 813467 times.
✓ Branch 1 taken 15179179 times.
✓ Branch 2 taken 611 times.
✓ Branch 3 taken 812856 times.
15992646 if(isInDungeon || special==spw_wizzrobe)
3674 {
3675
8/8
✓ Branch 0 taken 3127326 times.
✓ Branch 1 taken 12052464 times.
✓ Branch 2 taken 3020517 times.
✓ Branch 3 taken 106809 times.
✓ Branch 4 taken 3093839 times.
✓ Branch 5 taken 9065434 times.
✓ Branch 6 taken 3093825 times.
✓ Branch 7 taken 14 times.
15179790 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
3676 6114342 return true;
3677
3678
8/8
✓ Branch 0 taken 3054035 times.
✓ Branch 1 taken 6011413 times.
✓ Branch 2 taken 2971251 times.
✓ Branch 3 taken 82784 times.
✓ Branch 4 taken 3027621 times.
✓ Branch 5 taken 3066576 times.
✓ Branch 6 taken 3027618 times.
✓ Branch 7 taken 3 times.
9065448 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
3679
2/2
✓ Branch 0 taken 56336 times.
✓ Branch 1 taken 31 times.
5998869 if(special!=spw_door) // walk in door way
3680 56336 return true;
3681 3066610 }
3682
3683
6/6
✓ Branch 0 taken 1091848 times.
✓ Branch 1 taken 2787618 times.
✓ Branch 2 taken 426951 times.
✓ Branch 3 taken 664897 times.
✓ Branch 4 taken 34241 times.
✓ Branch 5 taken 392710 times.
3879466 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
3684 {
3685
3/4
✓ Branch 0 taken 1057600 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1057600 times.
2115207 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
3686
2/4
✓ Branch 0 taken 1057600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1057600 times.
✗ Branch 3 not taken.
1057600 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
3687 7 return true;
3688 1057600 }
3689
3690
4/4
✓ Branch 0 taken 3153082 times.
✓ Branch 1 taken 723388 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 2944 times.
3879459 switch(special)
3691 {
3692 case spw_clipbottomright:
3693
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
3694 45 break;
3695 case spw_clipright:
3696 2944 break; //if(input_x>=208) return true; break;
3697
3698 case spw_wizzrobe: // fall through
3699 case spw_floater: // Special case for fliers and wizzrobes - hack!
3700 {
3701
2/2
✓ Branch 0 taken 534198 times.
✓ Branch 1 taken 2618884 times.
3153082 if(isInDungeon)
3702 {
3703
3/4
✓ Branch 0 taken 2618873 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2618873 times.
2618884 if(dy < 32-yg || dy >= 144) return true;
3704
3/4
✓ Branch 0 taken 2618081 times.
✓ Branch 1 taken 792 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2618081 times.
2618873 if(dx < 32 || dx >= 224) return true;
3705 2618081 }
3706 3152279 return false;
3707 }
3708 }
3709
3710 726377 dx&=(special==spw_halfstep)?(~7):(~15);
3711
2/2
✓ Branch 0 taken 152931 times.
✓ Branch 1 taken 573446 times.
726377 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
3712
3713
2/2
✓ Branch 0 taken 84168 times.
✓ Branch 1 taken 642209 times.
726377 if(special==spw_water)
3714
2/2
✓ Branch 0 taken 5232 times.
✓ Branch 1 taken 78936 times.
84168 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
3715
3716
2/2
✓ Branch 0 taken 636979 times.
✓ Branch 1 taken 5230 times.
642209 if(get_bit(quest_rules,qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
3717 {
3718
4/4
✓ Branch 0 taken 479629 times.
✓ Branch 1 taken 157350 times.
✓ Branch 2 taken 475513 times.
✓ Branch 3 taken 4116 times.
1112492 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3719
2/2
✓ Branch 0 taken 2586 times.
✓ Branch 1 taken 472927 times.
475513 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3720 }
3721 else
3722 {
3723
4/4
✓ Branch 0 taken 4290 times.
✓ Branch 1 taken 940 times.
✓ Branch 2 taken 4182 times.
✓ Branch 3 taken 108 times.
9412 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
3724
4/4
✓ Branch 0 taken 4055 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 4042 times.
✓ Branch 3 taken 13 times.
4182 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
3725
3/4
✓ Branch 0 taken 3958 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 3958 times.
✗ Branch 3 not taken.
4042 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
3726
1/2
✓ Branch 0 taken 3958 times.
✗ Branch 1 not taken.
3958 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
3727 }
3728 4034573 }
3729
3730 424253 bool enemy::isOnSideviewPlatform()
3731 {
3732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 424253 times.
424253 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
3733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 424253 times.
424253 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
3734
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 413947 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
424253 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
3735
2/2
✓ Branch 0 taken 2205 times.
✓ Branch 1 taken 421837 times.
424042 if(check_slope(x, y+1, usewid, usehei)) return true;
3736
2/2
✓ Branch 0 taken 421837 times.
✓ Branch 1 taken 172374 times.
594211 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
3737 {
3738
2/2
✓ Branch 0 taken 172374 times.
✓ Branch 1 taken 249463 times.
421837 if(_walkflag(nx,y+usehei,1)) return true;
3739
3/4
✓ Branch 0 taken 172374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124615 times.
✓ Branch 3 taken 47759 times.
172374 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
3740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47759 times.
47759 if(checkSVLadderPlatform(nx,y+usehei)) return true;
3741 47759 }
3742 172374 return false;
3743 424253 }
3744
3745 // Stops playing the given sound only if there are no enemies left to play it
3746 323568 void enemy::stop_bgsfx(int32_t index)
3747 {
3748
2/2
✓ Branch 0 taken 315094 times.
✓ Branch 1 taken 8474 times.
323568 if(bgsfx<=0)
3749 315094 return;
3750
3751 // Look for other enemies with the same bgsfx
3752
2/2
✓ Branch 0 taken 35975 times.
✓ Branch 1 taken 4854 times.
40829 for(int32_t i=0; i<guys.Count(); i++)
3753 {
3754
4/4
✓ Branch 0 taken 30093 times.
✓ Branch 1 taken 5882 times.
✓ Branch 2 taken 3620 times.
✓ Branch 3 taken 26473 times.
35975 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
3755 3620 return;
3756 32355 }
3757
3758 4854 stop_sfx(bgsfx);
3759 323568 }
3760
3761
3762 // to allow for different sfx on defeating enemy
3763 16454 void enemy::death_sfx()
3764 {
3765
1/2
✓ Branch 0 taken 16454 times.
✗ Branch 1 not taken.
16454 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
3766 16454 }
3767
3768 void enemy::move(zfix dx,zfix dy)
3769 {
3770 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3771 {
3772 switch(family)
3773 {
3774 case eeFIRE:
3775 case eeOTHER:
3776 return;
3777 default: break;
3778 }
3779 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3780 }
3781 */
3782 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
3783 {
3784 x+=dx;
3785 y+=dy;
3786 }
3787 }
3788
3789 7730342 void enemy::move(zfix s)
3790 {
3791 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
3792 {
3793 switch(family)
3794 {
3795 case eeFIRE:
3796 case eeOTHER:
3797 return;
3798 default: break;
3799 }
3800 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
3801 }*/
3802
9/10
✓ Branch 0 taken 7730315 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 94766 times.
✓ Branch 3 taken 7635549 times.
✓ Branch 4 taken 41896 times.
✓ Branch 5 taken 52870 times.
✓ Branch 6 taken 2027 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 2027 times.
✗ Branch 9 not taken.
7730342 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
3803 {
3804 7728288 sprite::move(s);
3805 7728288 }
3806 7730342 }
3807
3808 17069 void enemy::leave_item()
3809 {
3810 17069 int32_t drop_item = select_dropitem(item_set, x, y);
3811 17069 int32_t thedropset = item_set;
3812
3813 17069 std::vector<int32_t> &ev = FFCore.eventData;
3814 17069 ev.clear();
3815 17069 ev.push_back(getUID());
3816 17069 ev.push_back(drop_item*10000);
3817 17069 ev.push_back(thedropset*10000);
3818
3819 17069 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
3820 17069 drop_item = vbound(ev[1] / 10000,-2,255);
3821 17069 thedropset = ev[2] / 10000;
3822 17069 ev.clear();
3823
1/2
✓ Branch 0 taken 17069 times.
✗ Branch 1 not taken.
17069 if(drop_item == -2)
3824 {
3825 drop_item = select_dropitem(thedropset,x,y);
3826 }
3827
3828
6/6
✓ Branch 0 taken 6904 times.
✓ Branch 1 taken 10165 times.
✓ Branch 2 taken 299 times.
✓ Branch 3 taken 6605 times.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 280 times.
17069 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
3829 {
3830 item* itm;
3831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6885 times.
6885 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
3832 {
3833 itm = (new item(x+hxofs+(hxsz/2)-8,y+hyofs+(hysz/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3834 }
3835 else
3836 {
3837
8/14
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 6602 times.
✓ Branch 2 taken 283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 283 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 283 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 283 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 283 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 283 times.
✗ Branch 13 not taken.
6885 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3838
4/8
✓ Branch 0 taken 6602 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6602 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6602 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6602 times.
✗ Branch 7 not taken.
6602 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
3839 }
3840 6885 itm->from_dropset = thedropset;
3841 6885 items.add(itm);
3842
3843 6885 ev.push_back(getUID());
3844 6885 ev.push_back(itm->getUID());
3845
3846 6885 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
3847 6885 ev.clear();
3848 6885 }
3849 17069 }
3850
3851 // auomatically kill off enemy (for rooms with ringleaders)
3852 289 void enemy::kickbucket()
3853 {
3854
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 25 times.
289 if(!superman)
3855 264 hp=-1000; // don't call death_sfx()
3856 289 }
3857
3858 90488 bool enemy::isSubmerged() const
3859 {
3860 90488 return submerged;
3861 //!TODO SOLIDPUSH more things like teleporting wizzrobes
3862 }
3863
3864 17356 void enemy::FireBreath(bool seekhero)
3865 {
3866
1/2
✓ Branch 0 taken 17356 times.
✗ Branch 1 not taken.
17356 if(wpn==wNone)
3867 return;
3868
3869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17356 times.
17356 if(wpn==ewFireTrail)
3870 {
3871 dmisc1 = e1tEACHTILE;
3872 FireWeapon();
3873 return;
3874 }
3875
3876 17356 float fire_angle=0.0;
3877 17356 int32_t wx=0, wy=0, wdir=dir;
3878
3879
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 15704 times.
17356 if(!seekhero)
3880 {
3881
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
3882 {
3883 case down:
3884 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
3885 3038 wx=x;
3886 3038 wy=y+8;
3887 3038 break;
3888
3889 case -1:
3890 case up:
3891 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
3892 3271 wx=x;
3893 3271 wy=y-8;
3894 3271 break;
3895
3896 case left:
3897 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
3898 5264 wx=x-8;
3899 5264 wy=y;
3900 5264 break;
3901
3902 case right:
3903 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
3904 4131 wx=x+8;
3905 4131 wy=y;
3906 4131 break;
3907 }
3908
3909
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
3910 {
3911
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
3912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
3913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
3914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
3915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
3916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
3917
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
3918
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
3919 15704 }
3920 15704 }
3921 else
3922 {
3923 1652 wx = x;
3924 1652 wy = y;
3925 }
3926
3927
2/2
✓ Branch 0 taken 1652 times.
✓ Branch 1 taken 15704 times.
17356 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
3928 17356 sfx(wpnsfx(wpn),pan(int32_t(x)));
3929
3930 17356 int32_t i=Ewpns.Count()-1;
3931 17356 weapon *ew = (weapon*)(Ewpns.spr(i));
3932 17356 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
3933
3934
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1652 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17356 if(!seekhero && (zc_oldrand()&4))
3935 {
3936 7874 ew->angular=true;
3937 7874 ew->angle=fire_angle;
3938 7874 }
3939
3940
4/4
✓ Branch 0 taken 17299 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 16982 times.
17356 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
3941 {
3942 16982 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
3943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16982 times.
16982 if ( ew->do_animation ) ew->tile+=ew->aframe;
3944 16982 }
3945
3946
2/2
✓ Branch 0 taken 17356 times.
✓ Branch 1 taken 542966 times.
560322 for(int32_t j=Ewpns.Count()-1; j>0; j--)
3947 {
3948 542966 Ewpns.swap(j,j-1);
3949 542966 }
3950 17356 }
3951
3952 21276 void enemy::FireWeapon()
3953 {
3954 /*
3955 * Type:
3956 * 0x01: Boss fireball
3957 * 0x02: Seeks Hero
3958 * 0x04: Fast projectile
3959 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
3960 */
3961
3962
1/2
✓ Branch 0 taken 21276 times.
✗ Branch 1 not taken.
21276 if (wpn < 1) return;
3963
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 21276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
21276 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
3964 return;
3965
3966
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 21276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21276 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
3967 dmisc1 = e1tEACHTILE;
3968
3969 21276 int32_t xoff = 0;
3970 21276 int32_t yoff = 0;
3971
1/2
✓ Branch 0 taken 21276 times.
✗ Branch 1 not taken.
21276 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
3972 {
3973 xoff += (hxsz/2)-8;
3974 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
3975 }
3976
1/2
✓ Branch 0 taken 21276 times.
✗ Branch 1 not taken.
21276 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
3977 {
3978 yoff += (hysz/2)-8;
3979 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
3980 }
3981
3982
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 19865 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
21276 switch(dmisc1)
3983 {
3984 case e1t5SHOTS: //BS-Aquamentus
3985 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
3986 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3987 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
3988 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3989
3990 [[fallthrough]];
3991 case e1t3SHOTSFAST:
3992 case e1t3SHOTS: //Aquamentus
3993
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
3994 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3995
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
3996 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
3997
3998 [[fallthrough]];
3999 default:
4000
11/20
✓ Branch 0 taken 20278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20278 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20278 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20278 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20278 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 20278 times.
✓ Branch 12 taken 20278 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10334 times.
✓ Branch 15 taken 9944 times.
✓ Branch 16 taken 20278 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 20278 times.
✗ Branch 19 not taken.
20278 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4001 20278 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4002 20278 sfx(wpnsfx(wpn),pan(int32_t(x)));
4003 20278 break;
4004
4005 case e1tSLANT:
4006 {
4007 409 int32_t slant = 0;
4008
4009
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
4010 236 slant = left;
4011
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
4012 112 slant = right;
4013
4014
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
4015 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4016 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
4017 319 break;
4018 }
4019
4020 case e1t8SHOTS: //Fire Wizzrobe
4021 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
4022 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4023 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4024 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
4025 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4026 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4027 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
4028 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4029 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4030 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
4031 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4032 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4033
4034 [[fallthrough]];
4035 case e1t4SHOTS: //Stalfos 3
4036
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
4037 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4038 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4039
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
4040 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4041 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4042
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
4043 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4044 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4045
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
4046 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
4047 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
4048 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
4049 589 break;
4050
4051 case e1tSUMMON: // Bat Wizzrobe
4052 {
4053 //al_trace("Summon Bats\n");
4054 //zprint2("Summon Bats\n");
4055 if(dmisc4==0) break; // Summon 0
4056
4057 int32_t bc=0;
4058
4059 for(int32_t gc=0; gc<guys.Count(); gc++)
4060 {
4061 if((((enemy*)guys.spr(gc))->id) == dmisc3)
4062 {
4063 ++bc;
4064 }
4065 }
4066
4067 if(bc<=40) // Not too many enemies
4068 {
4069 int32_t kids = guys.Count();
4070 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
4071
4072 for(int32_t i=0; i<bats; i++)
4073 {
4074 //zprint2("summon\n");
4075 //al_trace("summon\n");
4076 if(addchild(x,y,dmisc3,-10, this->script_UID))
4077 {
4078 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4079 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4080 //zprint2("Summoner Script UID: %d\n",this->script_UID);
4081
4082 }
4083 }
4084
4085 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4086 }
4087
4088 break;
4089 }
4090
4091 case e1tSUMMONLAYER: // Summoner
4092 {
4093 if(count_layer_enemies()==0)
4094 {
4095 break;
4096 }
4097
4098 int32_t kids = guys.Count();
4099
4100 if(kids<40)
4101 {
4102 int32_t newguys=(zc_oldrand()%3)+1;
4103 bool summoned=false;
4104
4105 for(int32_t i=0; i<newguys; i++)
4106 {
4107 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
4108 int32_t x2=0;
4109 int32_t y2=0;
4110
4111 for(int32_t k=0; k<20; ++k)
4112 {
4113 x2=16*((zc_oldrand()%12)+2);
4114 y2=16*((zc_oldrand()%7)+2);
4115
4116 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
4117 {
4118 //zprint2("summon\n");
4119 //al_trace("summon\n");
4120 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
4121 {
4122 ((enemy*)guys.spr(kids+i))->count_enemy = false;
4123 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
4124 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
4125 {
4126 ((enemy*)guys.spr(kids+i))->fakez = 64;
4127 ((enemy*)guys.spr(kids+i))->z = 0;
4128 }
4129 }
4130
4131 summoned=true;
4132 break;
4133 }
4134 }
4135 }
4136
4137 if(summoned)
4138 {
4139 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
4140 }
4141 }
4142
4143 break;
4144 }
4145 }
4146 21186 }
4147
4148
4149 // Hit the shield(s)?
4150 // Apparently, this function is only used for hookshots...
4151 89 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
4152 {
4153
4/6
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 43 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 43 times.
89 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
4154 43 return false;
4155
4156 46 bool ret = false;
4157
4158 // TODO: There must be some bitwise operations that can simplify this...
4159
8/12
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 25 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 21 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 21 times.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
46 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
4160
7/12
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 20 times.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
25 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
4161
4162
9/14
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 9 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 9 times.
✓ Branch 12 taken 9 times.
✗ Branch 13 not taken.
46 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
4163
9/14
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 28 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 28 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 28 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 28 times.
36 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
4164
4165 46 return ret;
4166 89 }
4167
4168
4169 //! Weapon Editor for 2.6
4170 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
4171
4172
4173 //converts a wqeapon ID to its defence index.
4174 57260 int32_t weaponToDefence(int32_t wid)
4175 {
4176
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 26558 times.
✓ Branch 3 taken 6326 times.
✓ Branch 4 taken 14566 times.
✓ Branch 5 taken 579 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 718 times.
✓ Branch 10 taken 5243 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 99 times.
✓ Branch 14 taken 560 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 298 times.
✓ Branch 18 taken 764 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 106 times.
✓ Branch 21 taken 89 times.
✓ Branch 22 taken 5 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 222 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 952 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
57260 switch(wid)
4177 {
4178 case wNone: return -1;
4179 26558 case wSword: return edefSWORD;
4180 6326 case wBeam: return edefBEAM;
4181 14566 case wBrang: return edefBRANG;
4182 579 case wBomb: return edefBOMB;
4183 27 case wSBomb: return edefSBOMB;
4184 48 case wLitBomb: return edefBOMB;
4185 case wLitSBomb: return edefSBOMB;
4186 718 case wArrow: return edefARROW;
4187 5243 case wFire: return edefFIRE;
4188 case wWhistle:
4189 {
4190 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
4191 return edefWhistle;
4192 }
4193 case wBait: return edefBAIT;
4194 99 case wWand: return edefWAND;
4195 560 case wMagic: return edefMAGIC;
4196 case wCatching: return -1;
4197 case wWind: return edefWIND;
4198 298 case wRefMagic: return edefREFMAGIC;
4199 764 case wRefFireball: return edefREFBALL;
4200 case wRefRock: return edefREFROCK;
4201 106 case wHammer: return edefHAMMER;
4202 89 case wHookshot: return edefHOOKSHOT;
4203 5 case wHSHandle: return edefHOOKSHOT;
4204 case wHSChain: return edefHOOKSHOT;
4205 case wSSparkle: return edefSPARKLE;
4206 222 case wFSparkle: return edefSPARKLE;
4207 case wSmack: return -1; // is this the candle object?
4208 case wPhantom: return -1; //engine created visual effects.
4209 case wCByrna: return edefBYRNA;
4210 11 case wRefBeam: return edefREFBEAM;
4211 case wStomp: return edefSTOMP;
4212 case wScript1: return edefSCRIPT01;
4213 case wScript2: return edefSCRIPT02;
4214 12 case wScript3: return edefSCRIPT03;
4215 77 case wScript4: return edefSCRIPT04;
4216 case wScript5: return edefSCRIPT05;
4217 case wScript6: return edefSCRIPT06;
4218 case wScript7: return edefSCRIPT07;
4219 case wScript8: return edefSCRIPT08;
4220 case wScript9: return edefSCRIPT09;
4221 952 case wScript10: return edefSCRIPT10;
4222 case wIce: return edefICE;
4223 case wSound: return edefSONIC;
4224 case wThrown: return edefTHROWN;
4225 //case wPot: return edefPOT;
4226 // case wLitZap: return edefELECTRIC;
4227 // case wZ3Sword: return edefZ3SWORD;
4228 // case wLASWord: return edefLASWORD;
4229 // case wSpinAttk: return edefSPINATTK;
4230 // case wShield: return edefSHIELD;
4231 // case wTrowel: return edefTROWEL;
4232
4233 default: return -1;
4234 }
4235 57260 }
4236
4237 57260 int32_t getDefType(weapon *w)
4238 {
4239 57260 int32_t id = getWeaponID(w);
4240 57260 int32_t edef = weaponToDefence(id);
4241
2/2
✓ Branch 0 taken 57166 times.
✓ Branch 1 taken 94 times.
57260 if(edef == edefHOOKSHOT)
4242 {
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if(w->family_class == itype_switchhook)
4244 return edefSwitchHook;
4245 94 }
4246 57260 return edef;
4247 57260 }
4248
4249 99865 int32_t getWeaponID(weapon *w)
4250 {
4251 99865 int32_t usewpn = w->useweapon;
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99865 times.
99865 return (usewpn > 0) ? usewpn : w->id;
4253 }
4254
4255 57260 int32_t enemy::resolveEnemyDefence(weapon *w)
4256 {
4257 //sword edef is 9, but we're reading it at 0
4258 //,
4259 57260 int32_t weapondef = 0;
4260 57260 int32_t wdeftype = getDefType(w);
4261 57260 int32_t usedef = w->usedefence;
4262
4263
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 57260 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
57260 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
4264 {
4265 weapondef = usedef*-1;
4266 }
4267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57260 times.
57260 else if(unsigned(wdeftype) < edefLAST255)
4268 {
4269 57260 weapondef = wdeftype;
4270 57260 }
4271 57260 return weapondef;
4272 }
4273
4274 62211 byte get_def_ignrflag(int32_t edef)
4275 {
4276
3/3
✓ Branch 0 taken 52136 times.
✓ Branch 1 taken 1864 times.
✓ Branch 2 taken 8211 times.
62211 switch(edef)
4277 {
4278 case edIGNORE:
4279 case edIGNOREL1:
4280 case edSTUNORIGNORE:
4281 8211 return WPNUNB_IGNR;
4282 case edSTUNORCHINK:
4283 case edCHINK:
4284 case edCHINKL1:
4285 case edCHINKL2:
4286 case edCHINKL4:
4287 case edCHINKL6:
4288 case edCHINKL8:
4289 case edCHINKL10:
4290 case edLEVELCHINK2:
4291 case edLEVELCHINK3:
4292 case edLEVELCHINK4:
4293 case edLEVELCHINK5:
4294 1864 return WPNUNB_BLOCK;
4295 }
4296 52136 return 0;
4297 62211 }
4298
4299 62211 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
4300 {
4301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62211 times.
62211 if(!(unblockable&get_def_ignrflag(edef))) return edef;
4302 switch(edef)
4303 {
4304 case edIGNORE:
4305 case edIGNOREL1:
4306 case edCHINK:
4307 case edCHINKL1:
4308 case edCHINKL2:
4309 case edCHINKL4:
4310 case edCHINKL6:
4311 case edCHINKL8:
4312 case edCHINKL10:
4313 case edLEVELCHINK2:
4314 case edLEVELCHINK3:
4315 case edLEVELCHINK4:
4316 case edLEVELCHINK5:
4317 return edNORMAL;
4318 case edSTUNORIGNORE:
4319 case edSTUNORCHINK:
4320 return edSTUNONLY;
4321 }
4322 return edef;
4323 62211 }
4324
4325 // Do we do damage?
4326 // 0: takehit returns 0
4327 // 1: takehit returns 1
4328 // -1: do damage
4329 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
4330 56308 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
4331 {
4332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56308 times.
56308 if(switch_hooked) return 0;
4333 56308 int32_t tempx = x;
4334 56308 int32_t tempy = y;
4335 56308 int32_t the_defence = 0;
4336
1/2
✓ Branch 0 taken 56308 times.
✗ Branch 1 not taken.
56308 if ( edef < 0 ) //we are using a specific base default defence for a weapon
4337 {
4338 the_defence = edef*-1; //A specific defence type.
4339 }
4340 56308 else the_defence = defense[edef];
4341
4342 56308 the_defence = conv_edef_unblockable(the_defence, unblockable);
4343
4344
3/4
✓ Branch 0 taken 3942 times.
✓ Branch 1 taken 52366 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3942 times.
56308 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
4345 {
4346
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 3941 times.
✓ Branch 2 taken 1 times.
3942 switch(the_defence)
4347 {
4348 case edIGNORE:
4349 1 return 0;
4350 case edIGNOREL1:
4351 case edSTUNORIGNORE:
4352 if(*power <= 0)
4353 return 0;
4354 }
4355 3941 sfx(WAV_CHINK,pan(int32_t(x)));
4356 3941 return 1;
4357 }
4358
4359 52366 int32_t new_id = id;
4360 52366 int32_t effect_type = dmisc15;
4361 52366 int32_t delay_timer = 90;
4362 52366 enemy *gleeok = NULL;
4363 52366 enemy *ptra = NULL;
4364 52366 int32_t c = 0;
4365
4366
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 182 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1242 times.
✓ Branch 6 taken 460 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 175 times.
✓ Branch 13 taken 6968 times.
✓ Branch 14 taken 135 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1386 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 41493 times.
52366 switch(the_defence)
4367 {
4368 case edREPLACE:
4369 {
4370 sclk = 0;
4371 if ( dmisc16 > 0 ) new_id = dmisc16;
4372 else new_id = id+1;
4373 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
4374 if ( dmisc17 > 0 ) delay_timer = dmisc17;
4375 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
4376
4377 //Z_scripterrlog("new id is %d\n", new_id);
4378 switch(guysbuf[new_id&0xFFF].family)
4379 {
4380 //Fixme: possible enemy memory leak. (minor)
4381 case eeWALK:
4382 {
4383 enemy *e = new eStalfos(x,y,new_id,clk);
4384 guys.add(e);
4385 }
4386 break;
4387
4388 case eeLEV:
4389 {
4390 enemy *e = new eLeever(x,y,new_id,clk);
4391 guys.add(e);
4392 }
4393 break;
4394
4395 case eeTEK:
4396 {
4397 enemy *e = new eTektite(x,y,new_id,clk);
4398 guys.add(e);
4399 }
4400 break;
4401
4402 case eePEAHAT:
4403 {
4404 enemy *e = new ePeahat(x,y,new_id,clk);
4405 guys.add(e);
4406 }
4407 break;
4408
4409 case eeZORA:
4410 {
4411 enemy *e = new eZora(x,y,new_id,clk);
4412 guys.add(e);
4413 }
4414 break;
4415
4416 case eeGHINI:
4417 {
4418 enemy *e = new eGhini(x,y,new_id,clk);
4419 guys.add(e);
4420 }
4421 break;
4422
4423 case eeKEESE:
4424 {
4425 enemy *e = new eKeese(x,y,new_id,clk);
4426 guys.add(e);
4427 }
4428 break;
4429
4430 case eeWIZZ:
4431 {
4432 enemy *e = new eWizzrobe(x,y,new_id,clk);
4433 guys.add(e);
4434 }
4435 break;
4436
4437 case eePROJECTILE:
4438 {
4439 enemy *e = new eProjectile(x,y,new_id,clk);
4440 guys.add(e);
4441 }
4442 break;
4443
4444 case eeWALLM:
4445 {
4446 enemy *e = new eWallM(x,y,new_id,clk);
4447 guys.add(e);
4448 }
4449 break;
4450
4451 case eeAQUA:
4452 {
4453 enemy *e = new eAquamentus(x,y,new_id,clk);
4454 guys.add(e);
4455 e->x = x;
4456 e->y = y;
4457 }
4458 break;
4459
4460 case eeMOLD:
4461 {
4462 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
4463 guys.add(e);
4464 e->x = x;
4465 e->y = y;
4466 }
4467 break;
4468
4469 case eeMANHAN:
4470 {
4471 enemy *e = new eManhandla(x,y,new_id,clk);
4472 guys.add(e);
4473 e->x = x;
4474 e->y = y;
4475 }
4476 break;
4477
4478 case eeGLEEOK:
4479 {
4480 *power = 0;
4481 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
4482 guys.add(gleeok);
4483 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4484 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4485 new_id &= 0xFFF;
4486 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4487 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4488 for(int32_t i=0; i<head_cnt; i++)
4489 {
4490 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4491 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4492 {
4493 al_trace("Gleeok head %d could not be created!\n",i+1);
4494
4495 for(int32_t j=0; j<i+1; j++)
4496 {
4497 guys.del(guys.Count()-1);
4498 }
4499
4500 break;
4501 }
4502 else
4503 {
4504 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4505 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4506 }
4507
4508 c-=guysbuf[new_id].misc4;
4509 //gleeok->x = x;
4510 //gleeok->y = y;
4511 //gleeok = e;
4512 }
4513 return 1;
4514 }
4515
4516 case eeGHOMA:
4517 {
4518 enemy *e = new eGohma(x,y,new_id,clk);
4519 guys.add(e);
4520 e->x = x;
4521 e->y = y;
4522 }
4523 break;
4524
4525 case eeLANM:
4526 {
4527 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
4528 guys.add(e);
4529 e->x = x;
4530 e->y = y;
4531 }
4532 break;
4533
4534 case eeGANON:
4535 {
4536 enemy *e = new eGanon(x,y,new_id,clk);
4537 guys.add(e);
4538 e->x = x;
4539 e->y = y;
4540 }
4541 break;
4542
4543 case eeFAIRY:
4544 {
4545 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
4546 guys.add(e);
4547 e->x = x;
4548 e->y = y;
4549 }
4550 break;
4551
4552 case eeFIRE:
4553 {
4554 enemy *e = new eFire(x,y,new_id,clk);
4555 guys.add(e);
4556 e->x = x;
4557 e->y = y;
4558 }
4559 break;
4560
4561 case eeOTHER:
4562 {
4563 enemy *e = new eOther(x,y,new_id,clk);
4564 guys.add(e);
4565 e->x = x;
4566 e->y = y;
4567 }
4568 break;
4569
4570 case eeSPINTILE:
4571 {
4572 enemy *e = new eSpinTile(x,y,new_id,clk);
4573 guys.add(e);
4574 e->x = x;
4575 e->y = y;
4576 }
4577 break;
4578
4579 // and these enemies use the misc10/misc2 value
4580 case eeROCK:
4581 {
4582 switch(guysbuf[new_id&0xFFF].misc10)
4583 {
4584 case 1:
4585 {
4586 enemy *e = new eBoulder(x,y,new_id,clk);
4587 guys.add(e);
4588 e->x = x;
4589 e->y = y;
4590 }
4591 break;
4592
4593 case 0:
4594 default:
4595 {
4596 enemy *e = new eRock(x,y,new_id,clk);
4597 guys.add(e);
4598 e->x = x;
4599 e->y = y;
4600 }
4601 break;
4602 }
4603
4604 break;
4605 }
4606
4607 case eeTRAP:
4608 {
4609 switch(guysbuf[new_id&0xFFF].misc2)
4610 {
4611 case 1:
4612 {
4613 enemy *e = new eTrap2(x,y,new_id,clk);
4614 guys.add(e);
4615 e->x = x;
4616 e->y = y;
4617 }
4618 break;
4619
4620 case 0:
4621 default:
4622 {
4623 enemy *e = new eTrap(x,y,new_id,clk);
4624 guys.add(e);
4625 e->x = x;
4626 e->y = y;
4627 }
4628 break;
4629 }
4630
4631 break;
4632 }
4633
4634 case eeDONGO:
4635 {
4636 switch(guysbuf[new_id&0xFFF].misc10)
4637 {
4638 case 1:
4639 {
4640 enemy *e = new eDodongo2(x,y,new_id,clk);
4641 guys.add(e);
4642 e->x = x;
4643 e->y = y;
4644 }
4645 break;
4646
4647 case 0:
4648 default:
4649 {
4650 enemy *e = new eDodongo(x,y,new_id,clk);
4651 guys.add(e);
4652 e->x = x;
4653 e->y = y;
4654 }
4655 break;
4656 }
4657
4658 break;
4659 }
4660
4661 case eeDIG:
4662 {
4663 switch(guysbuf[new_id&0xFFF].misc10)
4664 {
4665 case 1:
4666 {
4667 enemy *e = new eLilDig(x,y,new_id,clk);
4668 guys.add(e);
4669 e->x = x;
4670 e->y = y;
4671 }
4672 break;
4673
4674 case 0:
4675 default:
4676 {
4677 enemy *e = new eBigDig(x,y,new_id,clk);
4678 guys.add(e);
4679 e->x = x;
4680 e->y = y;
4681 }
4682 break;
4683 }
4684
4685 break;
4686 }
4687
4688 case eePATRA:
4689 {
4690 switch(guysbuf[new_id&0xFFF].misc10)
4691 {
4692 case 1:
4693 {
4694 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
4695 {
4696 enemy *e = new ePatraBS(x,y,new_id,clk);
4697 guys.add(e);
4698 e->x = x;
4699 e->y = y;
4700 break;
4701 }
4702 }
4703 [[fallthrough]];
4704 case 0:
4705 default:
4706 {
4707 enemy *e = new ePatra(x,y,new_id,clk);
4708 guys.add(e);
4709 e->x = x;
4710 e->y = y;
4711 }
4712 break;
4713 }
4714
4715 break;
4716 }
4717
4718 case eeGUY:
4719 {
4720 switch(guysbuf[new_id&0xFFF].misc10)
4721 {
4722 case 1:
4723 {
4724 enemy *e = new eTrigger(x,y,new_id,clk);
4725 guys.add(e);
4726 }
4727 break;
4728
4729 case 0:
4730 default:
4731 {
4732 enemy *e = new eNPC(x,y,new_id,clk);
4733 guys.add(e);
4734 }
4735 break;
4736 }
4737
4738 break;
4739 }
4740
4741 case eeSCRIPT01:
4742 case eeSCRIPT02:
4743 case eeSCRIPT03:
4744 case eeSCRIPT04:
4745 case eeSCRIPT05:
4746 case eeSCRIPT06:
4747 case eeSCRIPT07:
4748 case eeSCRIPT08:
4749 case eeSCRIPT09:
4750 case eeSCRIPT10:
4751 case eeSCRIPT11:
4752 case eeSCRIPT12:
4753 case eeSCRIPT13:
4754 case eeSCRIPT14:
4755 case eeSCRIPT15:
4756 case eeSCRIPT16:
4757 case eeSCRIPT17:
4758 case eeSCRIPT18:
4759 case eeSCRIPT19:
4760 case eeSCRIPT20:
4761 {
4762 enemy *e = new eScript(x,y,new_id,clk);
4763 guys.add(e);
4764 e->x = x;
4765 e->y = y;
4766 break;
4767 }
4768
4769
4770 case eeFFRIENDLY01:
4771 case eeFFRIENDLY02:
4772 case eeFFRIENDLY03:
4773 case eeFFRIENDLY04:
4774 case eeFFRIENDLY05:
4775 case eeFFRIENDLY06:
4776 case eeFFRIENDLY07:
4777 case eeFFRIENDLY08:
4778 case eeFFRIENDLY09:
4779 case eeFFRIENDLY10:
4780 {
4781 enemy *e = new eFriendly(x,y,new_id,clk);
4782 guys.add(e);
4783 e->x = x;
4784 e->y = y;
4785 break;
4786 }
4787
4788
4789 default: break;
4790 }
4791
4792 // add segments of segmented enemies
4793 int32_t c=0;
4794
4795 switch(guysbuf[new_id&0xFFF].family)
4796 {
4797 case eeMOLD:
4798 {
4799 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4800 new_id &= 0xFFF;
4801
4802 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
4803 {
4804 //christ this is messy -DD
4805 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
4806
4807 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
4808 {
4809 al_trace("Moldorm segment %d could not be created!\n",i+1);
4810
4811 for(int32_t j=0; j<i+1; j++)
4812 guys.del(guys.Count()-1);
4813
4814 return 0;
4815 }
4816
4817 if(i>0)
4818 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4819
4820
4821 }
4822
4823 break;
4824 }
4825
4826 case eeLANM:
4827 {
4828 new_id &= 0xFFF;
4829 int32_t shft = guysbuf[new_id].misc2;
4830 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
4831 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
4832
4833 if(!guys.add(e))
4834 {
4835 al_trace("Lanmola segment 1 could not be created!\n");
4836 guys.del(guys.Count()-1);
4837 return 0;
4838 }
4839 e->x = x;
4840 e->y = y;
4841
4842
4843
4844 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
4845 {
4846 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
4847 if(!guys.add(e2))
4848 {
4849 al_trace("Lanmola segment %d could not be created!\n",i+1);
4850
4851 for(int32_t j=0; j<i+1; j++)
4852 guys.del(guys.Count()-1);
4853
4854 return 0;
4855 }
4856 e2->x = x;
4857 e2->y = y;
4858
4859 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
4860
4861 }
4862 }
4863 break;
4864
4865 case eeMANHAN:
4866 new_id &= 0xFFF;
4867
4868 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
4869 {
4870 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
4871 {
4872 al_trace("Manhandla head %d could not be created!\n",i+1);
4873
4874 for(int32_t j=0; j<i+1; j++)
4875 {
4876 guys.del(guys.Count()-1);
4877 }
4878
4879 return 0;
4880 }
4881
4882
4883 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
4884 }
4885
4886 break;
4887
4888 case eeGLEEOK:
4889 {
4890 /*
4891 new_id &= 0xFFF;
4892 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
4893 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
4894 for(int32_t i=0; i<head_cnt; i++)
4895 {
4896 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
4897 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
4898 {
4899 al_trace("Gleeok head %d could not be created!\n",i+1);
4900
4901 for(int32_t j=0; j<i+1; j++)
4902 {
4903 guys.del(guys.Count()-1);
4904 }
4905
4906 break;
4907 }
4908
4909 c-=guysbuf[new_id].misc4;
4910 */
4911
4912 // }
4913 }
4914 break;
4915
4916
4917 case eePATRA:
4918 {
4919 new_id &= 0xFFF;
4920 int32_t outeyes = 0;
4921 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
4922
4923 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
4924 {
4925 if(!((guysbuf[new_id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
4926 {
4927 al_trace("Patra outer eye %d could not be created!\n",i+1);
4928
4929 for(int32_t j=0; j<i+1; j++)
4930 guys.del(guys.Count()-1);
4931
4932 return 0;
4933 }
4934 else
4935 outeyes++;
4936
4937
4938 }
4939
4940 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
4941 {
4942 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
4943 {
4944 al_trace("Patra inner eye %d could not be created!\n",i+1);
4945
4946 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
4947 guys.del(guys.Count()-1);
4948
4949 return 0;
4950 }
4951
4952
4953 }
4954 delete ptra;
4955 break;
4956 }
4957 }
4958
4959
4960
4961 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
4962 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
4963 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
4964 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
4965 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
4966 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
4967 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
4968 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
4969 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
4970 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
4971 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
4972 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
4973 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
4974 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
4975
4976
4977 item_set = 0; //Do not make a drop.
4978
4979 switch(effect_type)
4980 {
4981 case -7:
4982 {
4983 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
4984 Lwpns.add(w);
4985 break;
4986 }
4987 case -6:
4988 {
4989 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
4990 Lwpns.add(w);
4991 break;
4992 }
4993 case -5:
4994 {
4995 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
4996 Lwpns.add(w);
4997 break;
4998 }
4999 case -4:
5000 {
5001 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
5002 Lwpns.add(w);
5003 break;
5004 }
5005 case -3: explode(1); break;
5006 case -2: explode(2); break;
5007 case -1: explode(0); break;
5008 case 0: break;
5009
5010 default:
5011 {
5012 //Dummy weapon function
5013 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
5014 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
5015 Lwpns.add(w);
5016 break;
5017 }
5018 }
5019
5020
5021 yofs = -32768;
5022 switch(guysbuf[new_id&0xFFF].family)
5023 {
5024 case eeGLEEOK:
5025 {
5026 Z_scripterrlog("Replacing a gleeok.\n");
5027 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
5028 hp = -999;
5029 tempenemy->hp = -999;
5030 break;
5031
5032 }
5033 default:
5034 hp = -1000; break;
5035 }
5036 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
5037 return 1;
5038
5039 }
5040 case edSPLIT:
5041 {
5042 //int32_t ex = x; int32_t ey = y;
5043 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5044 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5045 /*
5046 if ( txsx > 1 )
5047 {
5048 ex += ( txsz-1 ) * 8; //from its middle
5049 }
5050 if ( tysx > 1 )
5051 {
5052 ey += ( tysz-1 ) * 8; //from its middle
5053 }
5054 */
5055 for ( int32_t q = 0; q < dmisc4; q++ )
5056 {
5057
5058 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
5059 addenemy(
5060 //ex,ey,
5061 x,y,
5062 dmisc3+0x1000,-15);
5063 //addenemy(ex,ey,dmisc3,0);
5064
5065 }
5066 item_set = 0; //Do not make a drop.
5067 hp = -1000;
5068 return -1;
5069
5070 }
5071 case edSUMMON:
5072 {
5073
5074
5075 //al_trace("edSplit dmisc3: %d\n", dmisc3);
5076 //al_trace("edSplit dmisc4: %d\n", dmisc4);
5077 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
5078 for ( int32_t q = 0; q < summon_count; q++ )
5079 {
5080 int32_t x2=16*((zc_oldrand()%12)+2);
5081 int32_t y2=16*((zc_oldrand()%7)+2);
5082 addenemy(
5083 //(x+(txsz*16)/2),(y+(tysz*16)/2)
5084 x2,y2,
5085 dmisc3+0x1000,-15);
5086 //addenemy(ex,ey,dmisc3,0);
5087
5088 }
5089 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
5090 return -1;
5091
5092 }
5093
5094 case edEXPLODESMALL:
5095 {
5096 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
5097 Ewpns.add(ew);
5098 item_set = 0; //Should we make a drop?
5099 hp = -1000;
5100 return -1;
5101 }
5102
5103
5104 case edEXPLODEHARMLESS:
5105 {
5106 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5107 Ewpns.add(ew);
5108 ew->hyofs = -32768;
5109 item_set = 0; //Should we make a drop?
5110 hp = -1000;
5111 return -1;
5112 }
5113
5114
5115 case edEXPLODELARGE:
5116 {
5117 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
5118 Ewpns.add(ew);
5119
5120 hp = -1000;
5121 return -1;
5122 }
5123
5124
5125 case edTRIGGERSECRETS:
5126 {
5127 hidden_entrance(0, true, false, -4);
5128 return -1;
5129 }
5130
5131 case edSTUNORCHINK:
5132
3/4
✓ Branch 0 taken 650 times.
✓ Branch 1 taken 736 times.
✓ Branch 2 taken 650 times.
✗ Branch 3 not taken.
2290 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5133 {
5134 sfx(WAV_CHINK,pan(int32_t(x)));
5135 return 1;
5136 }
5137
2/2
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 904 times.
1386 else if(*power <= 0)
5138 {
5139 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
5140 482 sfx(WAV_CHINK,pan(int32_t(x)));
5141 482 return 1;
5142 }
5143 [[fallthrough]];
5144
5145 case edSTUNORIGNORE:
5146
3/4
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 1128 times.
✗ Branch 3 not taken.
3639 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5147 {
5148 sfx(WAV_CHINK,pan(int32_t(x)));
5149 return 1;
5150 }
5151
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 1493 times.
2146 else if(*power <= 0)
5152 653 return 0;
5153 [[fallthrough]];
5154
5155 case edSTUNONLY:
5156
7/10
✓ Branch 0 taken 1953 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1953 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1953 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1936 times.
✓ Branch 7 taken 17 times.
✓ Branch 8 taken 1946 times.
✓ Branch 9 taken 7 times.
1953 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5157 {
5158 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5159 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
5160 7 return 1;
5161 }
5162
3/4
✓ Branch 0 taken 1438 times.
✓ Branch 1 taken 508 times.
✓ Branch 2 taken 1438 times.
✗ Branch 3 not taken.
1946 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK))
5163 {
5164 sfx(WAV_CHINK,pan(int32_t(x)));
5165 return 1;
5166 }
5167 else
5168 {
5169 1946 stunclk=160;
5170 1946 sfx(WAV_EHIT,pan(int32_t(x)));
5171
5172 1946 return 1;
5173 }
5174
5175 case edCHINKL1:
5176 if(*power >= 1*game->get_hero_dmgmult()) break;
5177 [[fallthrough]];
5178 case edCHINKL2:
5179
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
5180 [[fallthrough]];
5181 case edCHINKL4:
5182
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
5183 [[fallthrough]];
5184 case edCHINKL6:
5185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
5186 [[fallthrough]];
5187 case edCHINKL8:
5188
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
5189 [[fallthrough]];
5190 case edCHINKL10:
5191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
5192 [[fallthrough]];
5193 case edCHINK:
5194 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
5195 195 sfx(WAV_CHINK,pan(int32_t(x)));
5196 195 return 1;
5197
5198 case edIGNOREL1:
5199 if(*power > 0) break;
5200 [[fallthrough]];
5201
5202 case edIGNORE:
5203 6968 return 0;
5204
5205 case ed1HKO:
5206 182 *power = hp;
5207 182 return -2;
5208
5209 case ed2x:
5210 {
5211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 *power = zc_max(1,*power*2);
5212 //int32_t pow = *power;
5213 //*power = vbound((pow*2),0,214747);
5214 71 return -1;
5215 }
5216 case ed3x:
5217 {
5218 *power = zc_max(1,*power*3);
5219 //int32_t pow = *power;
5220 //*power = vbound((pow*3),0,214747);
5221 return -1;
5222 }
5223
5224 case ed4x:
5225 {
5226 *power = zc_max(1,*power*4);
5227 //int32_t pow = *power;
5228 //*power = vbound((pow*4),0,214747);
5229 return -1;
5230 }
5231
5232
5233 case edHEAL:
5234 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5235 //int32_t pow = *power;
5236 //*power = vbound((pow*-1),0,214747);
5237 //break;
5238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
5239 79 return -1;
5240 }
5241 /*
5242 case edLEVELDAMAGE:
5243 {
5244 int32_t pow = *power;
5245 int32_t lvl = *level;
5246 *power = vbound((pow*lvl),0,214747);
5247 break;
5248 }
5249 case edLEVELREDUCTION:
5250 {
5251 int32_t pow = *power;
5252 int32_t lvl = *level;
5253 *power = vbound((pow/lvl),0,214747);
5254 break;
5255 }
5256 */
5257
5258 case edQUARTDAMAGE:
5259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
58 *power = zc_max(1,*power/2);
5260
5261 [[fallthrough]];
5262 case edHALFDAMAGE:
5263
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 192 times.
193 *power = zc_max(1,*power/2);
5264 193 break;
5265
5266 case edSWITCH:
5267 {
5268 if(Hero.switchhookclk) return 0; //Already switching!
5269 switch(family)
5270 {
5271 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
5272 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
5273 return 0;
5274 }
5275 hooked_combopos = -1;
5276 hooked_layerbits = 0;
5277 switching_object = this;
5278 switch_hooked = true;
5279 Hero.doSwitchHook(game->get_switchhookstyle());
5280 if(QMisc.miscsfx[sfxSWITCHED])
5281 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
5282 return 1;
5283 }
5284
5285 case 0:
5286 {
5287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41493 times.
41493 if(edef == edefSwitchHook)
5288 return -1;
5289
6/6
✓ Branch 0 taken 10380 times.
✓ Branch 1 taken 31113 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 10351 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
41493 if (stunclk && get_bit(quest_rules, qr_NO_STUNLOCK) && *power == 0)
5290 {
5291 13 sfx(WAV_CHINK,pan(int32_t(x)));
5292 13 return 1;
5293 }
5294
5295 }
5296 41480 }
5297
5298 41770 return -1;
5299 56308 }
5300
5301 56308 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
5302 {
5303
1/2
✓ Branch 0 taken 56308 times.
✗ Branch 1 not taken.
56308 int wuid = w?w->getUID():0;
5304
1/2
✓ Branch 0 taken 56308 times.
✗ Branch 1 not taken.
56308 bool fakeweap = (w && !Lwpns.getByUID(wuid));
5305
5306
1/2
✓ Branch 0 taken 56308 times.
✗ Branch 1 not taken.
56308 if(fakeweap)
5307 Lwpns.add(w);
5308 56308 std::vector<int32_t> &ev = FFCore.eventData;
5309 56308 ev.clear();
5310 56308 ev.push_back(*power*10000);
5311 56308 ev.push_back(edef*10000);
5312 56308 ev.push_back(unblockable*10000);
5313 56308 ev.push_back(wpnId*10000);
5314 56308 ev.push_back(0);
5315 56308 ev.push_back(getUID());
5316 56308 ev.push_back(wuid);
5317
5318 56308 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
5319 56308 *power = ev[0]/10000;
5320 56308 edef = ev[1]/10000;
5321 56308 unblockable = byte(ev[2]/10000);
5322 56308 wpnId = ev[3] / 10000;
5323 56308 bool nullify = ev[4]!=0;
5324 56308 ev.clear();
5325 56308 int ret = 0;
5326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56308 times.
56308 if(!nullify)
5327 {
5328 56308 ret = defendNew(wpnId, power, edef, unblockable);
5329
2/2
✓ Branch 0 taken 15028 times.
✓ Branch 1 taken 41280 times.
56308 if(ret == -1)
5330 {
5331 41280 ev.push_back(*power*10000);
5332 41280 ev.push_back(edef*10000);
5333 41280 ev.push_back(unblockable*10000);
5334 41280 ev.push_back(wpnId*10000);
5335 41280 ev.push_back(0);
5336 41280 ev.push_back(getUID());
5337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41280 times.
41280 ev.push_back(w?w->getUID():0);
5338
5339 41280 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
5340 41280 *power = ev[0]/10000;
5341 41280 nullify = ev[4]!=0;
5342 41280 ev.clear();
5343 41280 }
5344 56308 }
5345
1/2
✓ Branch 0 taken 56308 times.
✗ Branch 1 not taken.
56308 if(fakeweap)
5346 Lwpns.remove(w);
5347
5348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56308 times.
56308 return nullify ? 0 : ret;
5349 }
5350
5351 42605 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
5352 {
5353
2/2
✓ Branch 0 taken 42402 times.
✓ Branch 1 taken 203 times.
42605 if(!realweap) realweap = w;
5354 42605 int32_t wid = getWeaponID(w);
5355
5356 42605 int32_t edef = resolveEnemyDefence(w);
5357
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 41345 times.
42605 if(QHeader.zelda_version > 0x250)
5358 1260 return defendNewInt(wid, power, edef, w->unblockable, realweap);
5359
2/3
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 40393 times.
✗ Branch 2 not taken.
41345 switch(wid)
5360 {
5361 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
5362 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
5363 952 return defend(wpnId, power, edefSCRIPT);
5364
5365 case wWhistle:
5366 return -1;
5367
5368 default:
5369 40393 return defendNewInt(wid, power, edef, w->unblockable, realweap);
5370 }
5371 42605 }
5372
5373
5374 // Check defenses without actually acting on them.
5375 6129 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
5376 {
5377
4/10
✓ Branch 0 taken 4176 times.
✓ Branch 1 taken 1723 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
6129 switch(defense[edef])
5378 {
5379 case edSTUNONLY:
5380 8 return false;
5381 case edSTUNORCHINK:
5382 case edCHINK:
5383 4176 return unblockable&WPNUNB_BLOCK;
5384 case edSTUNORIGNORE:
5385 case edIGNORE:
5386 1723 return unblockable&WPNUNB_IGNR;
5387
5388 case edIGNOREL1:
5389 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
5390 case edCHINKL1:
5391 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
5392
5393 case edCHINKL2:
5394 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
5395
5396 case edCHINKL4:
5397 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
5398
5399 case edCHINKL6:
5400 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
5401
5402 case edCHINKL8:
5403 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
5404 }
5405
5406 222 return true;
5407 6129 }
5408
5409 // Do we do damage?
5410 // 0: takehit returns 0
5411 // 1: takehit returns 1
5412 // -1: do damage
5413 952 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
5414 {
5415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 952 times.
952 if(shieldCanBlock)
5416 {
5417 switch(defense[edef])
5418 {
5419 case edIGNORE:
5420 return 0;
5421 case edIGNOREL1:
5422 case edSTUNORIGNORE:
5423 if(*power <= 0)
5424 return 0;
5425 }
5426
5427 sfx(WAV_CHINK,pan(int32_t(x)));
5428 return 1;
5429 }
5430
5431
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 759 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
952 switch(defense[edef])
5432 {
5433 case edSTUNORCHINK:
5434 if(*power <= 0)
5435 {
5436 sfx(WAV_CHINK,pan(int32_t(x)));
5437 return 1;
5438 }
5439
5440 [[fallthrough]];
5441 case edSTUNORIGNORE:
5442 if(*power <= 0)
5443 return 0;
5444
5445 [[fallthrough]];
5446 case edSTUNONLY:
5447 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
5448 return 1;
5449
5450 stunclk=160;
5451 sfx(WAV_EHIT,pan(int32_t(x)));
5452 return 1;
5453
5454 case edFREEZE:
5455 frozenclock=-1;
5456 //sfx(WAV_FREEZE,pan(int32_t(x)));
5457 return 1;
5458
5459 case edCHINKL1:
5460 if(*power >= 1*game->get_hero_dmgmult()) break;
5461 [[fallthrough]];
5462 case edCHINKL2:
5463 if(*power >= 2*game->get_hero_dmgmult()) break;
5464 [[fallthrough]];
5465 case edCHINKL4:
5466 if(*power >= 4*game->get_hero_dmgmult()) break;
5467 [[fallthrough]];
5468 case edCHINKL6:
5469 if(*power >= 6*game->get_hero_dmgmult()) break;
5470 [[fallthrough]];
5471 case edCHINKL8:
5472 if(*power >= 8*game->get_hero_dmgmult()) break;
5473 [[fallthrough]];
5474 case edCHINKL10:
5475 if(*power >= 10*game->get_hero_dmgmult()) break;
5476 [[fallthrough]];
5477 case edCHINK:
5478 sfx(WAV_CHINK,pan(int32_t(x)));
5479 return 1;
5480 case edTRIGGERSECRETS:
5481 hidden_entrance(0, true, false, -4);
5482 break;
5483
5484 case edIGNOREL1:
5485 if(*power > 0) break;
5486 [[fallthrough]];
5487 case edIGNORE:
5488 759 return 0;
5489
5490 case ed1HKO:
5491 *power = hp;
5492 return -2;
5493
5494 case ed2x:
5495 {
5496 *power = zc_max(1,*power*2);
5497 //int32_t pow = *power;
5498 //*power = vbound((pow*2),0,214747);
5499 return -1;
5500 }
5501 case ed3x:
5502 {
5503 *power = zc_max(1,*power*3);
5504 //int32_t pow = *power;
5505 //*power = vbound((pow*3),0,214747);
5506 return -1;
5507 }
5508
5509 case ed4x:
5510 {
5511 *power = zc_max(1,*power*4);
5512 //int32_t pow = *power;
5513 //*power = vbound((pow*4),0,214747);
5514 return -1;
5515 }
5516
5517
5518 case edHEAL:
5519 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
5520 //int32_t pow = *power;
5521 //*power = vbound((pow*-1),0,214747);
5522 //break;
5523 *power = zc_min(0,*power*-1);
5524 return -1;
5525 }
5526 /*
5527 case edLEVELDAMAGE:
5528 {
5529 int32_t pow = *power;
5530 int32_t lvl = *level;
5531 *power = vbound((pow*lvl),0,214747);
5532 break;
5533 }
5534 case edLEVELREDUCTION:
5535 {
5536 int32_t pow = *power;
5537 int32_t lvl = *level;
5538 *power = vbound((pow/lvl),0,214747);
5539 break;
5540 }
5541 */
5542
5543
5544 case edQUARTDAMAGE:
5545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
5546
5547 [[fallthrough]];
5548 case edHALFDAMAGE:
5549
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 *power = zc_max(1,*power/2);
5550 7 break;
5551 }
5552
5553 193 return -1;
5554 952 }
5555
5556 // Defend against a particular item class.
5557 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
5558 {
5559 int32_t def=-1;
5560
5561 switch(wpnId)
5562 {
5563 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
5564 case wBrang:
5565 def = defend(wpnId, power, edefBRANG);
5566 break;
5567
5568 case wHookshot:
5569 def = defend(wpnId, power, edefHOOKSHOT);
5570 break;
5571
5572 // Anyway...
5573 case wBomb:
5574 def = defend(wpnId, power, edefBOMB);
5575 break;
5576
5577 case wSBomb:
5578 def = defend(wpnId, power, edefSBOMB);
5579 break;
5580
5581 case wArrow:
5582 def = defend(wpnId, power, edefARROW);
5583 break;
5584
5585 case wFire:
5586 def = defend(wpnId, power, edefFIRE);
5587 break;
5588
5589 case wWand:
5590 def = defend(wpnId, power, edefWAND);
5591 break;
5592
5593 case wMagic:
5594 def = defend(wpnId, power, edefMAGIC);
5595 break;
5596
5597 case wHammer:
5598 def = defend(wpnId, power, edefHAMMER);
5599 break;
5600
5601 case wSword:
5602 def = defend(wpnId, power, edefSWORD);
5603 break;
5604
5605 case wBeam:
5606 def = defend(wpnId, power, edefBEAM);
5607 break;
5608
5609 case wRefBeam:
5610 def = defend(wpnId, power, edefREFBEAM);
5611 break;
5612
5613 case wRefMagic:
5614 def = defend(wpnId, power, edefREFMAGIC);
5615 break;
5616
5617 case wRefFireball:
5618 def = defend(wpnId, power, edefREFBALL);
5619 break;
5620
5621 case wRefRock:
5622 def = defend(wpnId, power, edefREFROCK);
5623 break;
5624
5625 case wStomp:
5626 def = defend(wpnId, power, edefSTOMP);
5627 break;
5628
5629 case wCByrna:
5630 def = defend(wpnId, power, edefBYRNA);
5631 break;
5632
5633 case wScript1:
5634 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
5635 else def = defend(wpnId, power, edefSCRIPT);
5636 break;
5637
5638 case wScript2:
5639 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
5640 else def = defend(wpnId, power, edefSCRIPT);
5641 break;
5642
5643 case wScript3:
5644 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
5645 else def = defend(wpnId, power, edefSCRIPT);
5646 break;
5647
5648 case wScript4:
5649 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
5650 else def = defend(wpnId, power, edefSCRIPT);
5651 break;
5652
5653 case wScript5:
5654 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
5655 else def = defend(wpnId, power, edefSCRIPT);
5656 break;
5657
5658 case wScript6:
5659 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
5660 else def = defend(wpnId, power, edefSCRIPT);
5661 break;
5662
5663 case wScript7:
5664 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
5665 else def = defend(wpnId, power, edefSCRIPT);
5666 break;
5667
5668 case wScript8:
5669 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
5670 else def = defend(wpnId, power, edefSCRIPT);
5671 break;
5672
5673 case wScript9:
5674 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
5675 else def = defend(wpnId, power, edefSCRIPT);
5676 break;
5677
5678 case wScript10:
5679 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
5680 else def = defend(wpnId, power, edefSCRIPT);
5681 break;
5682
5683 case wWhistle:
5684 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
5685 else break;
5686 break;
5687
5688
5689 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
5690 //Probably best to do this from the qest file, loading the values of Script(generic) into each
5691 //of the ten if the quest version is lower than N.
5692 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
5693 //such as bool UseSeparatedScriptDefences. hah.
5694 default:
5695 //if(wpnId>=wScript1 && wpnId<=wScript10)
5696 // {
5697 // def = defend(wpnId, power, edefSCRIPT);
5698 // }
5699 // }
5700
5701 break;
5702 }
5703
5704 return def;
5705 }
5706
5707 // take damage or ignore it
5708 // -1: damage (if any) dealt
5709 // 1: blocked
5710 // 0: weapon passes through unhindered
5711 127704 int32_t enemy::takehit(weapon *w, weapon* realweap)
5712 {
5713
2/4
✓ Branch 0 taken 127704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127704 times.
127704 if(fallclk||drownclk) return 0;
5714
2/2
✓ Branch 0 taken 27639 times.
✓ Branch 1 taken 100065 times.
127704 if(!realweap) realweap = w;
5715 127704 int32_t wpnId = w->id;
5716 127704 int32_t power = w->power;
5717 127704 int32_t wpnx = w->x;
5718 127704 int32_t wpny = w->y;
5719 127704 int32_t enemyHitWeapon = w->parentitem;
5720 int32_t wpnDir;
5721 127704 int32_t parent_item = w->parentitem;
5722
5723
1/2
✓ Branch 0 taken 127704 times.
✗ Branch 1 not taken.
127704 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
5724 {
5725 wpnId = w->useweapon;
5726 }
5727
5728 // If it's a boomerang that just bounced, use the opposite direction;
5729 // otherwise, it might bypass a shield. This probably won't handle
5730 // every case correctly, but it's better than having shields simply
5731 // not work against boomerangs.
5732
8/8
✓ Branch 0 taken 14581 times.
✓ Branch 1 taken 113123 times.
✓ Branch 2 taken 9126 times.
✓ Branch 3 taken 5455 times.
✓ Branch 4 taken 8764 times.
✓ Branch 5 taken 362 times.
✓ Branch 6 taken 2032 times.
✓ Branch 7 taken 6732 times.
127704 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
5733 6732 wpnDir = oppositeDir[w->dir];
5734 else
5735 120972 wpnDir = w->dir;
5736
5737
5/8
✓ Branch 0 taken 127704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 127704 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 127704 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1054 times.
✓ Branch 7 taken 126650 times.
127704 if(dying || clk<0 || hclk>0 || superman)
5738 1054 return 0;
5739
5740 //Prevent boomerang from writing to hitby[] for more than one frame.
5741 //This also prevents stunlock.
5742 //if ( stunclk > 0 ) return 0;
5743 //this needs a rule for boomerangs that cannot stunlock!
5744 //further, bouncing weapons should probably SFX_CHINK and bounce here.
5745 //sigh.
5746
5747 126650 int32_t ret = -1;
5748
5749 // This obscure quest rule...
5750
5/6
✓ Branch 0 taken 74238 times.
✓ Branch 1 taken 52412 times.
✓ Branch 2 taken 74110 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74110 times.
126650 if(get_bit(quest_rules,qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
5751 {
5752 double _MSVC2022_tmp1, _MSVC2022_tmp2;
5753 128 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
5754 128 wpnDir=zc_oldrand()&3;
5755
5756
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 53 times.
128 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
5757 {
5758 53 wpnDir=down;
5759 53 }
5760
4/4
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 36 times.
75 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
5761 {
5762 36 wpnDir=right;
5763 36 }
5764
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 7 times.
39 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
5765 {
5766 7 wpnDir=up;
5767 7 }
5768 else
5769 {
5770 32 wpnDir=left;
5771 }
5772 128 }
5773
5774 126650 int32_t xdir = dir;
5775 126650 shieldCanBlock=false;
5776
5777 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
5778
4/4
✓ Branch 0 taken 126262 times.
✓ Branch 1 taken 388 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 126173 times.
127444 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
5779
10/10
✓ Branch 0 taken 10809 times.
✓ Branch 1 taken 10720 times.
✓ Branch 2 taken 14193 times.
✓ Branch 3 taken 122700 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 122644 times.
✓ Branch 6 taken 982 times.
✓ Branch 7 taken 121662 times.
✓ Branch 8 taken 794 times.
✓ Branch 9 taken 120868 times.
126262 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
5780 )
5781 // The hammer should already be dealt with by subclasses (Walker etc.)
5782 {
5783
9/9
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 182 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 3465 times.
✓ Branch 4 taken 245 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 497 times.
✓ Branch 8 taken 394 times.
26834 switch(wpnId)
5784 {
5785 // Weapons which shields protect against
5786 case wSword:
5787 case wWand:
5788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3465 times.
3465 if(Hero.getCharging()>0)
5789 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
5790
5791 [[fallthrough]];
5792 case wHookshot:
5793 case wHSHandle:
5794 case wBrang:
5795 3647 shieldCanBlock=true;
5796 3892 break;
5797
5798 case wBeam:
5799 case wRefBeam:
5800 // Mirror shielded enemies!
5801 #if 0
5802 if(false /*flags2&guy_mirror*/ && !get_bit(quest_rules,qr_SWORDMIRROR))
5803 {
5804 if(wpnId>wEnemyWeapons)
5805 return 0;
5806
5807 sfx(WAV_CHINK,pan(int32_t(x)));
5808 return 1;
5809 }
5810
5811 #endif
5812
5813 [[fallthrough]];
5814 case wRefRock:
5815 case wRefFireball:
5816 case wMagic:
5817 #if 0
5818 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_bit(quest_rules,qr_REFLECTROCKS)))
5819 {
5820 sfx(WAV_CHINK,pan(int32_t(x)));
5821 return 3;
5822 }
5823
5824 #endif
5825
5826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257 times.
257 if(wpnId>wEnemyWeapons)
5827 return 0;
5828
5829 [[fallthrough]];
5830 default:
5831 754 shieldCanBlock=true;
5832 754 break;
5833
5834 // Bombs
5835 case wSBomb:
5836 case wBomb:
5837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_bit(quest_rules,qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
5838 else if (!get_bit(quest_rules,qr_BOMBSPIERCESHIELD))
5839 {
5840 sfx(WAV_CHINK,pan(int32_t(x)));
5841 return 0;
5842 }
5843 else break;
5844
5845 // Weapons which ignore shields
5846 case wWhistle:
5847 case wHammer:
5848 1 break;
5849
5850 // Weapons which shouldn't be removed by shields
5851 case wLitBomb:
5852 case wLitSBomb:
5853 case wWind:
5854 case wPhantom:
5855 case wSSparkle:
5856 case wBait:
5857 416 return 0;
5858
5859 [[fallthrough]];
5860 case wFire:
5861 #if 0
5862 if(false /*flags2&guy_mirror*/)
5863 {
5864 sfx(WAV_CHINK,pan(int32_t(x)));
5865 return 1;
5866 }
5867
5868 #endif
5869 ;
5870 394 }
5871 4796 }
5872
5873
7/8
✓ Branch 0 taken 62573 times.
✓ Branch 1 taken 42175 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6129 times.
✓ Branch 5 taken 14566 times.
✓ Branch 6 taken 89 times.
✓ Branch 7 taken 356 times.
126052 switch(wpnId)
5874 {
5875 case wWhistle: //No longer completely ignore whistle weapons! -Z
5876 {
5877
5878
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 164 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
164 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
5879 {
5880 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
5881 164 return 0; break;
5882 }
5883 else
5884 {
5885 w->power = power = itemsbuf[parent_item].misc5;
5886
5887 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
5888
5889 if(def <= 0)
5890 {
5891 if ( def == -2 ) hp -= hp;
5892 else hp -= power;
5893 return def;
5894 }
5895 break;
5896 }
5897 break;
5898 }
5899
5900 case wPhantom:
5901 return 0;
5902
5903 case wLitBomb:
5904 case wLitSBomb:
5905 case wBait:
5906 case wWind:
5907 case wSSparkle:
5908 62573 return 0;
5909
5910 case wFSparkle:
5911
5912 // Only take sparkle damage if the sparkle's parent item is not
5913 // defended against.
5914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6129 times.
6129 if(enemyHitWeapon > -1)
5915 {
5916 6129 int32_t p = 0;
5917 6129 int32_t f = itemsbuf[enemyHitWeapon].family;
5918
5919
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6129 times.
6129 switch(f)
5920 {
5921 case itype_arrow:
5922 if(!candamage(p, edefARROW, w->unblockable)) return 0;
5923
5924 break;
5925
5926 case itype_cbyrna:
5927 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
5928
5929 break;
5930
5931 case itype_brang:
5932
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 5907 times.
6129 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
5933
5934 222 break;
5935
5936 default:
5937 return 0;
5938 }
5939 222 }
5940
5941 222 wpnId = wSword;
5942 222 power = game->get_hero_dmgmult()>>1;
5943 222 goto fsparkle;
5944 break;
5945
5946 case wBrang:
5947 {
5948 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
5949 14566 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
5950 //preventing stunlock might be best, here. -Z
5951
2/2
✓ Branch 0 taken 3640 times.
✓ Branch 1 taken 10926 times.
14566 if(def >= 0) return def;
5952
5953 // Not hurt by 0-damage weapons
5954
2/2
✓ Branch 0 taken 1866 times.
✓ Branch 1 taken 9060 times.
10926 if(!(flags & guy_bhit))
5955 {
5956 9060 stunclk=160;
5957
5958
3/4
✓ Branch 0 taken 9060 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1047 times.
✓ Branch 3 taken 8013 times.
9060 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
5959 {
5960
1/2
✓ Branch 0 taken 1047 times.
✗ Branch 1 not taken.
1047 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
5961 1047 goto hitclock;
5962 }
5963
5964 8013 break;
5965 }
5966
5967
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 1511 times.
1866 if(!power)
5968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1511 times.
1511 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
5969 else
5970 355 hp-=power;
5971
5972 1866 goto hitclock;
5973 }
5974
5975 case wHookshot:
5976 {
5977 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
5978 89 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
5979
5980
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 68 times.
89 if(def >= 0) return def;
5981
5982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
5983
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
68 if(swgrab || !(flags & guy_bhit))
5984 {
5985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 if(!swgrab)
5986 68 stunclk=160;
5987
5988
2/4
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 68 times.
68 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
5989 {
5990 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
5991 goto hitclock;
5992 }
5993
5994 68 break;
5995 }
5996
5997 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
5998 else
5999 hp-=power;
6000
6001 goto hitclock;
6002 }
6003 break;
6004
6005 case wHSHandle:
6006 {
6007
3/4
✓ Branch 0 taken 356 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 277 times.
356 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
6008 79 return 0;
6009
6010
3/4
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
277 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
6011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
67 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
6012
6013 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
6014
5/8
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 210 times.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 67 times.
332 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
6015
6/6
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 117 times.
✓ Branch 4 taken 55 times.
✓ Branch 5 taken 62 times.
67 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
6016 62 return 0;
6017
6018 425 power = game->get_hero_dmgmult();
6019 647 }
6020
6021 fsparkle:
6022
6023 [[fallthrough]];
6024 default:
6025 // Work out the defenses!
6026 {
6027 42402 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
6028
6029
2/2
✓ Branch 0 taken 11833 times.
✓ Branch 1 taken 30569 times.
42402 if(def >= 0)
6030 11833 return def;
6031
2/2
✓ Branch 0 taken 30419 times.
✓ Branch 1 taken 150 times.
30569 else if(def == -2)
6032 {
6033 150 ret = 0;
6034 150 }
6035 }
6036
6037
2/2
✓ Branch 0 taken 30567 times.
✓ Branch 1 taken 2 times.
61138 if(!power)
6038 {
6039
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
6040 2 hp-=1;
6041 else
6042 {
6043 // Don't make a long chain of 'stun' hits
6044 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
6045 return 1;
6046
6047
6048 if(!switch_hooked)
6049 stunclk=160;
6050 break;
6051 }
6052 2 }
6053 30567 else hp-=power;
6054
6055 hitclock:
6056 33486 hclk=33;
6057
6058 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
6059
2/2
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 17704 times.
33486 if((dir&2)==(w->dir&2))
6060 {
6061 17704 sclk=(w->dir<<8)+16;
6062 17704 }
6063 33486 }
6064
6065
5/6
✓ Branch 0 taken 30641 times.
✓ Branch 1 taken 10926 times.
✓ Branch 2 taken 1962 times.
✓ Branch 3 taken 39605 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1962 times.
41567 if(((wpnId==wBrang) || (get_bit(quest_rules,qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
6066 {
6067 1962 fading=fade_blue_poof;
6068 1962 }
6069
6070
6/6
✓ Branch 0 taken 40561 times.
✓ Branch 1 taken 1006 times.
✓ Branch 2 taken 34206 times.
✓ Branch 3 taken 6355 times.
✓ Branch 4 taken 1328 times.
✓ Branch 5 taken 32878 times.
41567 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
6071 {
6072
1/2
✓ Branch 0 taken 2334 times.
✗ Branch 1 not taken.
2334 if( hitsfx > 0 ) //user-set hit sound.
6073 {
6074
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2334 times.
2334 if (!dying) //don't play the hit sound on death! -Z
6075 2334 sfx(hitsfx, pan(int32_t(x)));
6076 2334 }
6077 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
6078 2334 }
6079 else //2.50.2 or earlier
6080 {
6081 39233 sfx(WAV_EHIT, pan(int32_t(x)));
6082 39233 sfx(hitsfx, pan(int32_t(x)));
6083 }
6084
2/2
✓ Branch 0 taken 41564 times.
✓ Branch 1 taken 3 times.
41567 if(family==eeGUY)
6085 3 sfx(WAV_EDEAD, pan(int32_t(x)));
6086
6087 // Penetrating weapons
6088
4/4
✓ Branch 0 taken 41120 times.
✓ Branch 1 taken 447 times.
✓ Branch 2 taken 36482 times.
✓ Branch 3 taken 5085 times.
41567 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
6089 {
6090 5085 int32_t item=enemyHitWeapon;
6091
6092
2/2
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 4759 times.
5085 if(wpnId==wArrow)
6093 {
6094 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6095
5/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 199 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
326 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
6096 59 return 0;
6097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 267 times.
267 else if(get_bit(quest_rules,qr_ARROWS_ALWAYS_PENETRATE)) return 0;
6098 //if(item<0)
6099 else
6100 267 item=current_item_id(itype_arrow);
6101 267 }
6102
6103 else
6104 {
6105
6106 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
6107
2/6
✓ Branch 0 taken 4759 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4759 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4759 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
6108 return 0;
6109
6110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4759 times.
4759 else if(get_bit(quest_rules,qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
6111 else
6112 //if(item<0)
6113 4759 item=current_item_id(itype_sword);
6114 }
6115 5026 }
6116
6117 41508 return ret;
6118 127316 }
6119
6120 21850068 bool enemy::dont_draw()
6121 {
6122
6/6
✓ Branch 0 taken 21749299 times.
✓ Branch 1 taken 100769 times.
✓ Branch 2 taken 21678392 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 30972 times.
✓ Branch 5 taken 21718327 times.
21850068 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6123 131741 return true;
6124
6125
2/2
✓ Branch 0 taken 213288 times.
✓ Branch 1 taken 21505039 times.
21718327 if(flags&guy_invisible)
6126 213288 return true;
6127
6128
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 21504607 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
21505039 if(flags&lens_only && !lensclk)
6129 return true;
6130
6131
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 21459088 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
21505039 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
6132 !((flags&lens_only) && (get_bit(quest_rules,qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
6133 return true;
6134
6135 21505039 return false;
6136 21850068 }
6137
6138 #define DRAW_NORMAL 2
6139 #define DRAW_CLOAKED 1
6140 #define DRAW_INVIS 0
6141 // base drawing function to be used by all derived classes instead of
6142 // sprite::draw()
6143 18926406 void enemy::draw(BITMAP *dest)
6144 {
6145
6/6
✓ Branch 0 taken 18648620 times.
✓ Branch 1 taken 277786 times.
✓ Branch 2 taken 18565970 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 134965 times.
✓ Branch 5 taken 18513655 times.
18926406 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
6146 412751 return;
6147
2/2
✓ Branch 0 taken 1432295 times.
✓ Branch 1 taken 17081360 times.
18513655 if(flags&guy_invisible)
6148 1432295 return;
6149
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 17055102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17081360 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
6150 return;
6151
6152 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
6153 // be cloaked if they have "invisible displays as cloaked" checked.
6154
6155 17081360 byte canSee = DRAW_NORMAL;
6156 //Enemy specific stuff
6157
1/2
✓ Branch 0 taken 17081360 times.
✗ Branch 1 not taken.
17081360 if ( editorflags & ENEMY_FLAG1 )
6158 {
6159 canSee = DRAW_INVIS;
6160 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
6161 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
6162 {
6163 if (game->item[dmisc13])
6164 {
6165 canSee = DRAW_NORMAL;
6166 }
6167 //else if ( lensclk && getlensid.flags SHOWINVIS )
6168 //{
6169 //
6170 //}
6171 //else
6172 //{
6173 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
6174 // //otherwisem invisible
6175 //}
6176 }
6177 }
6178 //Room specific
6179
2/2
✓ Branch 0 taken 16993114 times.
✓ Branch 1 taken 88246 times.
17081360 if (tmpscr->flags3&fINVISROOM)
6180 {
6181
4/6
✓ Branch 0 taken 88246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15679 times.
✓ Branch 3 taken 72567 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15679 times.
103925 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
6182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15679 times.
15679 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
6183 88246 }
6184 //Lens check
6185
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 17055102 times.
17081360 if (lensclk)
6186 {
6187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
6188 {
6189 if (canSee == DRAW_NORMAL)
6190 {
6191 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
6192 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
6193 }
6194 }
6195
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
6196 {
6197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
6198 432 }
6199 26258 }
6200 else
6201 {
6202
2/2
✓ Branch 0 taken 16981686 times.
✓ Branch 1 taken 73416 times.
17055102 if(flags&lens_only)
6203 73416 canSee = DRAW_INVIS;
6204 }
6205
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 17007944 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
17081360 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
6206
3/4
✓ Branch 0 taken 16992265 times.
✓ Branch 1 taken 89095 times.
✓ Branch 2 taken 16992265 times.
✗ Branch 3 not taken.
17081360 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
6207
6208
2/2
✓ Branch 0 taken 17007944 times.
✓ Branch 1 taken 73416 times.
17081360 if (canSee == DRAW_INVIS)
6209 73416 return;
6210
6211
3/4
✓ Branch 0 taken 17007802 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17007802 times.
17007944 if(fallclk||drownclk)
6212 {
6213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
6214 {
6215 sprite::drawcloaked(dest);
6216 }
6217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
6218 {
6219 142 sprite::draw(dest);
6220 142 }
6221 142 return;
6222 }
6223 17007802 int32_t cshold=cs;
6224
6225
2/2
✓ Branch 0 taken 391623 times.
✓ Branch 1 taken 16616179 times.
17007802 if(dying)
6226 {
6227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391623 times.
391623 if(clk2>=19)
6228 {
6229 if(!(clk2&2))
6230 {
6231 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
6232 if (canSee == DRAW_CLOAKED)
6233 {
6234 sprite::drawcloaked(dest);
6235 }
6236 else if (canSee == DRAW_NORMAL)
6237 {
6238 sprite::draw(dest);
6239 }
6240 }
6241 return;
6242 }
6243
6244 391623 flip = 0;
6245 391623 tile = wpnsbuf[spr_death].tile;
6246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 391623 times.
391623 if ( do_animation )
6247 {
6248 391623 int32_t offs = 0;
6249
2/2
✓ Branch 0 taken 386816 times.
✓ Branch 1 taken 4807 times.
391623 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6250 {
6251
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
6252 {
6253 239 spr_death_anim_clk=0;
6254 239 clk2=1;
6255
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
6256 235 death_sfx();
6257 239 }
6258
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
6259 {
6260 4456 ++clk2;
6261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6262
1/2
✓ Branch 0 taken 4456 times.
✗ Branch 1 not taken.
4456 spr_death_anim_frm *= zc_max(1,txsz);
6263 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6264
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 73 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6265
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
✓ Branch 2 taken 4456 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✓ Branch 5 taken 4217 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6266 {
6267 239 spr_death_anim_clk=-1;
6268 239 clk2=1;
6269 239 }
6270 4456 }
6271 4807 tile += spr_death_anim_frm;
6272 4807 }
6273
2/2
✓ Branch 0 taken 6579 times.
✓ Branch 1 taken 380237 times.
386816 else if(BSZ)
6274 {
6275
2/2
✓ Branch 0 taken 5178 times.
✓ Branch 1 taken 1401 times.
6579 offs = zc_min((15-clk2)/3,4);
6276 6579 }
6277
4/4
✓ Branch 0 taken 253528 times.
✓ Branch 1 taken 126709 times.
✓ Branch 2 taken 126598 times.
✓ Branch 3 taken 126930 times.
380237 else if(clk2>6 && clk2<=12)
6278 {
6279 126930 offs = 1;
6280 126930 }
6281
6282
2/2
✓ Branch 0 taken 259056 times.
✓ Branch 1 taken 132567 times.
391623 if(offs)
6283 {
6284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132567 times.
132567 offs *= zc_max(1,txsz);
6285 132567 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
6286
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 132519 times.
132567 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6287 132567 }
6288 391623 tile += offs;
6289 391623 }
6290
6291
6/6
✓ Branch 0 taken 386816 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 380237 times.
✓ Branch 3 taken 6579 times.
✓ Branch 4 taken 63806 times.
✓ Branch 5 taken 316431 times.
391623 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6292 75192 cs = wpnsbuf[spr_death].csets&15;
6293 else
6294 316431 cs = (((clk2+5)>>1)&3)+6;
6295 391623 }
6296
3/4
✓ Branch 0 taken 543796 times.
✓ Branch 1 taken 16072383 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 543796 times.
16616179 else if(hclk>0 && getCanFlicker())
6297 {
6298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 543796 times.
543796 if(family==eeGANON)
6299 cs=(((hclk-1)>>1)&3)+6;
6300
4/4
✓ Branch 0 taken 504043 times.
✓ Branch 1 taken 39753 times.
✓ Branch 2 taken 174114 times.
✓ Branch 3 taken 329929 times.
543796 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6301 329929 cs=(((hclk-1)>>1)&3)+6;
6302 543796 }
6303 //draw every other frame for flickering enemies
6304
8/10
✓ Branch 0 taken 8495178 times.
✓ Branch 1 taken 8512624 times.
✓ Branch 2 taken 8495178 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 461184 times.
✓ Branch 5 taken 8033994 times.
✓ Branch 6 taken 137054 times.
✓ Branch 7 taken 324130 times.
✓ Branch 8 taken 137054 times.
✗ Branch 9 not taken.
17007802 if((frame&1)==1 || !(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER) && getCanFlicker()))
6305 {
6306
2/2
✓ Branch 0 taken 15508 times.
✓ Branch 1 taken 16855240 times.
16870748 if (canSee == DRAW_CLOAKED)
6307 {
6308 15508 sprite::drawcloaked(dest);
6309 15508 }
6310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16855240 times.
16855240 else if (canSee == DRAW_NORMAL)
6311 {
6312
1/2
✓ Branch 0 taken 16855240 times.
✗ Branch 1 not taken.
16855240 if ( frozenclock < 0 )
6313 {
6314 if ( frozentile > 0 ) tile = frozentile;
6315 loadpalset(csBOSS,frozencset);
6316 }
6317 16855240 sprite::draw(dest);
6318 16855240 }
6319 16870748 }
6320 17007802 cs=cshold;
6321 18926406 }
6322
6323 //old zc bosses
6324 17391598 void enemy::drawzcboss(BITMAP *dest)
6325 {
6326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17391598 times.
17391598 if(dont_draw())
6327 return;
6328
6329 17391598 int32_t cshold=cs;
6330
6331
2/2
✓ Branch 0 taken 352019 times.
✓ Branch 1 taken 17039579 times.
17391598 if(dying)
6332 {
6333
2/2
✓ Branch 0 taken 2520 times.
✓ Branch 1 taken 349499 times.
352019 if(clk2>=19)
6334 {
6335
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 1260 times.
2520 if(!(clk2&2))
6336 1260 sprite::drawzcboss(dest);
6337
6338 2520 return;
6339 }
6340
6341 349499 flip = 0;
6342 349499 tile = wpnsbuf[spr_death].tile;
6343
6344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 349499 times.
349499 if ( do_animation )
6345 {
6346
2/2
✓ Branch 0 taken 347313 times.
✓ Branch 1 taken 2186 times.
349499 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS))
6347 {
6348
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
6349 {
6350 2 spr_death_anim_clk=0;
6351 2 clk2=1;
6352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
6353 2 death_sfx();
6354 2 }
6355
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
6356 {
6357 2 ++clk2;
6358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
6359
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm *= zc_max(1,txsz);
6360 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
6361
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
6362
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
6363 {
6364 spr_death_anim_clk=-1;
6365 clk2=1;
6366 }
6367 2 }
6368 2186 tile += spr_death_anim_frm;
6369 2186 }
6370
2/2
✓ Branch 0 taken 6579 times.
✓ Branch 1 taken 340734 times.
347313 else if(BSZ)
6371
2/2
✓ Branch 0 taken 5178 times.
✓ Branch 1 taken 1401 times.
6579 tile += zc_min((15-clk2)/3,4);
6372
4/4
✓ Branch 0 taken 227078 times.
✓ Branch 1 taken 113656 times.
✓ Branch 2 taken 113399 times.
✓ Branch 3 taken 113679 times.
340734 else if(clk2>6 && clk2<=12)
6373 113679 ++tile;
6374 349499 }
6375
6376
6/6
✓ Branch 0 taken 347313 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 340734 times.
✓ Branch 3 taken 6579 times.
✓ Branch 4 taken 60782 times.
✓ Branch 5 taken 279952 times.
349499 if(!get_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
6377 69547 cs = wpnsbuf[spr_death].csets&15;
6378 else
6379 279952 cs = (((clk2+5)>>1)&3)+6;
6380 349499 }
6381
2/2
✓ Branch 0 taken 16506809 times.
✓ Branch 1 taken 532770 times.
17039579 else if(hclk>0)
6382 {
6383
2/2
✓ Branch 0 taken 1944 times.
✓ Branch 1 taken 530826 times.
532770 if(family==eeGANON)
6384 1944 cs=(((hclk-1)>>1)&3)+6;
6385
4/4
✓ Branch 0 taken 496294 times.
✓ Branch 1 taken 34532 times.
✓ Branch 2 taken 110465 times.
✓ Branch 3 taken 385829 times.
530826 else if(hclk<33 && !get_bit(quest_rules,qr_ENEMIESFLICKER))
6386 385829 cs=(((hclk-1)>>1)&3)+6;
6387 532770 }
6388
6389
2/4
✓ Branch 0 taken 72353 times.
✓ Branch 1 taken 17316725 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17389078 if((tmpscr->flags3&fINVISROOM) &&
6390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72353 times.
72353 !(current_item(itype_amulet)) &&
6391 !(get_bit(quest_rules,qr_LENSSEESENEMIES) &&
6392 lensclk) && family!=eeGANON)
6393 {
6394 sprite::drawcloaked(dest);
6395 }
6396 else
6397 {
6398
6/6
✓ Branch 0 taken 17375414 times.
✓ Branch 1 taken 13664 times.
✓ Branch 2 taken 864561 times.
✓ Branch 3 taken 16510853 times.
✓ Branch 4 taken 705056 times.
✓ Branch 5 taken 159505 times.
17389078 if(family !=eeGANON && hclk>0 && get_bit(quest_rules,qr_ENEMIESFLICKER))
6399 {
6400
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 143685 times.
159505 if((frame&1)==1)
6401 143685 sprite::drawzcboss(dest);
6402 159505 }
6403 else
6404 17229573 sprite::drawzcboss(dest);
6405 }
6406
6407 17389078 cs=cshold;
6408 17391598 }
6409
6410
6411 // similar to the overblock function--can do up to a 32x32 sprite
6412 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
6413 113584 void enemy::drawblock(BITMAP *dest,int32_t mask)
6414 {
6415 113584 int32_t thold=tile;
6416 113584 int32_t t1=tile;
6417 113584 int32_t t2=tile+20;
6418 113584 int32_t t3=tile+1;
6419 113584 int32_t t4=tile+21;
6420
6421
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 113584 times.
113584 switch(mask)
6422 {
6423 case 1:
6424 enemy::drawzcboss(dest);
6425 break;
6426
6427 case 3:
6428 if(flip&2)
6429 zc_swap(t1,t2);
6430
6431 tile=t1;
6432 enemy::drawzcboss(dest);
6433 tile=t2;
6434 yofs+=16;
6435 enemy::drawzcboss(dest);
6436 yofs-=16;
6437 break;
6438
6439 case 5:
6440 t2=tile+1;
6441
6442 if(flip&1)
6443 zc_swap(t1,t2);
6444
6445 tile=t1;
6446 enemy::drawzcboss(dest);
6447 tile=t2;
6448 xofs+=16;
6449 enemy::drawzcboss(dest);
6450 xofs-=16;
6451 break;
6452
6453 case 15:
6454
2/2
✓ Branch 0 taken 111236 times.
✓ Branch 1 taken 2348 times.
113584 if(flip&1)
6455 {
6456 2348 zc_swap(t1,t3);
6457 2348 zc_swap(t2,t4);
6458 2348 }
6459
6460
1/2
✓ Branch 0 taken 113584 times.
✗ Branch 1 not taken.
113584 if(flip&2)
6461 {
6462 zc_swap(t1,t2);
6463 zc_swap(t3,t4);
6464 }
6465
6466 113584 tile=t1;
6467 113584 enemy::drawzcboss(dest);
6468 113584 tile=t2;
6469 113584 yofs+=16;
6470 113584 enemy::drawzcboss(dest);
6471 113584 yofs-=16;
6472 113584 tile=t3;
6473 113584 xofs+=16;
6474 113584 enemy::drawzcboss(dest);
6475 113584 tile=t4;
6476 113584 yofs+=16;
6477 113584 enemy::drawzcboss(dest);
6478 113584 xofs-=16;
6479 113584 yofs-=16;
6480 113584 break;
6481 }
6482
6483 113584 tile=thold;
6484 113584 }
6485
6486 4261611 void enemy::drawshadow(BITMAP *dest, bool translucent)
6487 {
6488
4/4
✓ Branch 0 taken 3916582 times.
✓ Branch 1 taken 345029 times.
✓ Branch 2 taken 430389 times.
✓ Branch 3 taken 3486193 times.
4261611 if(dont_draw() || isSideViewGravity())
6489 {
6490 775418 return;
6491 }
6492
6493
2/2
✓ Branch 0 taken 59397 times.
✓ Branch 1 taken 3426796 times.
3486193 if(dying)
6494 {
6495 59397 return;
6496 }
6497
6498
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3426796 times.
✓ Branch 2 taken 145552 times.
✓ Branch 3 taken 3281244 times.
3426796 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
6499 3426796 (darkroom))
6500 {
6501 145552 return;
6502 }
6503 else
6504 {
6505
4/4
✓ Branch 0 taken 3164030 times.
✓ Branch 1 taken 117214 times.
✓ Branch 2 taken 3155778 times.
✓ Branch 3 taken 8252 times.
3281244 if(enemycanfall(id, false) && shadowtile == 0)
6506 8252 shadowtile = wpnsbuf[spr_shadow].tile;
6507
6508
5/6
✓ Branch 0 taken 2709194 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 2709194 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2591980 times.
✓ Branch 5 taken 117214 times.
3281244 if(z>0 || fakez>0 || !enemycanfall(id, false))
6509 {
6510
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 689148 times.
689264 if(!shadow_overpit(this))
6511 689148 sprite::drawshadow(dest,translucent);
6512 689264 }
6513 }
6514 4261611 }
6515
6516 67181 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
6517 {
6518 67181 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
6519
6520
1/2
✓ Branch 0 taken 67181 times.
✗ Branch 1 not taken.
67181 if(sub!=NULL)
6521 {
6522 67181 xofs-=mx;
6523 67181 yofs-=my;
6524 67181 enemy::draw(sub);
6525 67181 xofs+=mx;
6526 67181 yofs+=my;
6527 67181 destroy_bitmap(sub);
6528 67181 }
6529 else
6530 enemy::draw(dest);
6531 67181 }
6532
6533 // override hit detection to check for invicibility, stunned, etc
6534 52704 bool enemy::hit(sprite *s)
6535 {
6536
3/6
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52704 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 52704 times.
52704 if(!(s->scriptcoldet&1) || s->fallclk || s->drownclk) return false;
6537
6538
2/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52704 times.
✗ Branch 3 not taken.
52704 return (dying || hclk>0) ? false : sprite::hit(s);
6539 52704 }
6540
6541 21163961 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
6542 {
6543
4/4
✓ Branch 0 taken 20806038 times.
✓ Branch 1 taken 357923 times.
✓ Branch 2 taken 20204646 times.
✓ Branch 3 taken 601392 times.
21163961 return (dying || hclk>0) ? false : sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
6544 }
6545 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
6546 {
6547 return (dying || hclk>0) ? false : sprite::hit(tx,ty,txsz2,tysz2);
6548 }
6549
6550 5962827 bool enemy::hit(weapon *w)
6551 {
6552
4/6
✓ Branch 0 taken 5865572 times.
✓ Branch 1 taken 97255 times.
✓ Branch 2 taken 5865572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5865572 times.
5962827 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
6553
6554
4/4
✓ Branch 0 taken 5697476 times.
✓ Branch 1 taken 168096 times.
✓ Branch 2 taken 5419009 times.
✓ Branch 3 taken 278467 times.
5865572 return (dying || hclk>0) ? false : sprite::hit(w);
6555 5962827 }
6556
6557 5501417 bool enemy::can_pitfall(bool checkspawning)
6558 {
6559
4/4
✓ Branch 0 taken 5494852 times.
✓ Branch 1 taken 6565 times.
✓ Branch 2 taken 5492063 times.
✓ Branch 3 taken 9354 times.
5501417 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
6560
2/2
✓ Branch 0 taken 5486725 times.
✓ Branch 1 taken 5338 times.
5492063 switch(guysbuf[id&0xFFF].family)
6561 {
6562 case eeAQUA:
6563 case eeDIG:
6564 case eeDONGO:
6565 case eeFAIRY:
6566 case eeGANON:
6567 case eeGHOMA:
6568 case eeGLEEOK:
6569 case eeGUY:
6570 case eeLANM:
6571 case eeMANHAN:
6572 case eeMOLD:
6573 case eeNONE:
6574 case eePATRA:
6575 case eeZORA:
6576 5338 return false; //Disallowed types
6577 default:
6578 5486725 return true;
6579 }
6580 5501417 }
6581 //Handle death
6582 15718850 void enemy::try_death(bool force_kill)
6583 {
6584
8/8
✓ Branch 0 taken 15711973 times.
✓ Branch 1 taken 6877 times.
✓ Branch 2 taken 15711971 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 16964 times.
✓ Branch 5 taken 15695007 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 16963 times.
15718850 if(!dying && (force_kill || (hp<=0 && !immortal)))
6585 {
6586 16965 std::vector<int32_t> &ev = FFCore.eventData;
6587 16965 ev.clear();
6588 16965 ev.push_back(10000);
6589 16965 ev.push_back(getUID());
6590
6591 16965 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
6592 16965 bool isSaved = !ev[0];
6593 16965 ev.clear();
6594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16965 times.
16965 if(isSaved) return;
6595
6596
4/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 16946 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 17 times.
16965 if(itemguy && (hasitem&2)!=0)
6597 {
6598
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 17 times.
37 for(int32_t i=0; i<items.Count(); i++)
6599 {
6600
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 17 times.
20 if(((item*)items.spr(i))->pickup&ipENEMY)
6601 {
6602
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
6603 {
6604 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
6605 {
6606 items.spr(i)->x = x+hxofs+(hxsz/2)-8;
6607 items.spr(i)->y = y+hyofs+(hysz/2)-10-fakez;
6608 }
6609 else
6610 {
6611 if(extend >= 3)
6612 {
6613 items.spr(i)->x = x+(txsz-1)*8;
6614 items.spr(i)->y = y-2+(tysz-1)*8;
6615 }
6616 else
6617 {
6618 items.spr(i)->x = x;
6619 items.spr(i)->y = y - 2;
6620 }
6621 }
6622 items.spr(i)->z = z;
6623 items.spr(i)->fakez = fakez;
6624 }
6625 else
6626 {
6627 17 items.spr(i)->x = x;
6628 17 items.spr(i)->y = y - 2;
6629 }
6630 17 }
6631 20 }
6632 17 }
6633
6634 16965 dying=true;
6635
6636
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 16944 times.
16965 if(fading==fade_flash_die)
6637 21 clk2=19+18*4;
6638 else
6639 {
6640 16944 clk2 = BSZ ? 15 : 19;
6641
6642
2/2
✓ Branch 0 taken 2033 times.
✓ Branch 1 taken 14911 times.
16944 if(fading!=fade_blue_poof)
6643 14911 fading=0;
6644 }
6645
6646
2/2
✓ Branch 0 taken 16946 times.
✓ Branch 1 taken 19 times.
16965 if(itemguy)
6647 {
6648 19 hasitem&=~2;
6649 19 item_set=0;
6650 19 }
6651
6652
6/6
✓ Branch 0 taken 16304 times.
✓ Branch 1 taken 661 times.
✓ Branch 2 taken 12596 times.
✓ Branch 3 taken 3708 times.
✓ Branch 4 taken 48 times.
✓ Branch 5 taken 12548 times.
16965 if(currscr<128 && count_enemy && !script_spawned)
6653 12548 game->guys[(currmap<<7)+currscr]-=1;
6654 16965 }
6655 15718850 }
6656
6657 // --==**==--
6658
6659 // Movement routines that can be used by derived classes as needed
6660
6661 // --==**==--
6662
6663 241875 void enemy::fix_coords(bool bound)
6664 {
6665
1/2
✓ Branch 0 taken 241875 times.
✗ Branch 1 not taken.
241875 if ((get_bit(quest_rules,qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
6666
1/2
✓ Branch 0 taken 241875 times.
✗ Branch 1 not taken.
241875 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
6667
6668
6669
2/2
✓ Branch 0 taken 32007 times.
✓ Branch 1 taken 209868 times.
241875 if(bound)
6670 {
6671
1/2
✓ Branch 0 taken 209868 times.
✗ Branch 1 not taken.
209868 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
6672 {
6673
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 209868 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209868 x=vbound(x, 0, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256-((txsz-1)*16)) : 240));
6674
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 209868 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
209868 y=vbound(y, 0,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176-((txsz-1)*16)) : 160));
6675 209868 }
6676 else
6677 {
6678 x=vbound(x, 0,240);
6679 y=vbound(y, 0,160);
6680 }
6681 209868 }
6682
6683
6/10
✓ Branch 0 taken 239917 times.
✓ Branch 1 taken 1958 times.
✓ Branch 2 taken 241875 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 241875 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 241875 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 241875 times.
241875 if(!OUTOFBOUNDS)
6684 {
6685 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
6686
6687 if(isSideViewGravity())
6688 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
6689 else
6690 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
6691 */
6692 241875 do_fix(x, 16, true);
6693
2/2
✓ Branch 0 taken 1958 times.
✓ Branch 1 taken 239917 times.
241875 if(isSideViewGravity())
6694 1958 do_fix(y,8,true);
6695 239917 else do_fix(y,16,true);
6696 241875 }
6697 241875 }
6698 5289 bool enemy::cannotpenetrate()
6699 {
6700
4/4
✓ Branch 0 taken 5191 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 5175 times.
5289 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
6701 }
6702
6703 349 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6704 {
6705 bool ok;
6706 349 int32_t dx = 0, dy = 0;
6707 349 int32_t sv = 8;
6708
6709 //Why is this here??? Why is it needed???
6710 349 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6711
6712
8/9
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 53 times.
✓ Branch 6 taken 38 times.
✓ Branch 7 taken 51 times.
✗ Branch 8 not taken.
349 switch(ndir)
6713 {
6714 case 8:
6715 case up:
6716
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
41 if(canfall(id) && isSideViewGravity())
6717 return false;
6718
6719 41 dy = dy1-s;
6720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 special = (special==spw_clipbottomright)?spw_none:special;
6721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6722 41 break;
6723
6724 case 12:
6725 case down:
6726
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
34 if(canfall(id) && isSideViewGravity())
6727 return false;
6728
6729 34 dy = dy2+s;
6730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
6731 34 break;
6732
6733 case 14:
6734 case left:
6735 25 dx = dx1-s;
6736 25 sv = ((isSideViewGravity())?7:8);
6737
2/4
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
25 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6738
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 24 times.
25 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6739 25 break;
6740
6741 case 10:
6742 case right:
6743 46 dx = dx2+s;
6744 46 sv = ((isSideViewGravity())?7:8);
6745
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 42 times.
46 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
6746 46 break;
6747
6748 case 9:
6749 case r_up:
6750 61 dx = dx2+s;
6751 61 dy = dy1-s;
6752
3/4
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✓ Branch 3 taken 1 times.
121 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6754 61 break;
6755
6756 case 11:
6757 case r_down:
6758 53 dx = dx2+s;
6759 53 dx = dy2+s;
6760
2/4
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
106 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6762 53 break;
6763
6764 case 13:
6765 case l_down:
6766 38 dx = dx1-s;
6767 38 dy = dy2+s;
6768
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
74 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6770 38 break;
6771
6772 case 15:
6773 case l_up:
6774 51 dx = dx1-s;
6775 51 dy = dy1-s;
6776
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
102 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
6777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
6778 51 break;
6779
6780 default:
6781 db=99;
6782 return true;
6783 }
6784
6785 349 return ok;
6786 349 }
6787
6788
6789
6790
6791 // returns true if next step is ok, false if there is something there
6792 2895645 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
6793 {
6794 2895645 bool ok = false; //initialise the var, son't just declare it
6795 2895645 int32_t dx = 0, dy = 0;
6796 2895645 int32_t sv = 8;
6797 2895645 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
6798 //Why is this here??? Why is it needed???
6799 2895645 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
6800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
6801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
6802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
6803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
6804 2895645 bool offgrid = OFFGRID_ENEMY;
6805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2895645 times.
2895645 if(!offgrid)
6806 {
6807 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
6808
1/2
✓ Branch 0 taken 2895645 times.
✗ Branch 1 not taken.
2895645 if(usehei<16)usehei=16;
6809
1/2
✓ Branch 0 taken 2895645 times.
✗ Branch 1 not taken.
2895645 if(usewid<16)usewid=16;
6810 2895645 }
6811
9/9
✓ Branch 0 taken 533110 times.
✓ Branch 1 taken 425970 times.
✓ Branch 2 taken 472597 times.
✓ Branch 3 taken 485200 times.
✓ Branch 4 taken 223241 times.
✓ Branch 5 taken 270134 times.
✓ Branch 6 taken 249156 times.
✓ Branch 7 taken 236113 times.
✓ Branch 8 taken 124 times.
2895645 switch(ndir) //need to check every 8 pixels between two points
6812 {
6813 case 8:
6814 case up:
6815 {
6816
4/4
✓ Branch 0 taken 96108 times.
✓ Branch 1 taken 437002 times.
✓ Branch 2 taken 95327 times.
✓ Branch 3 taken 781 times.
533110 if(enemycanfall(id) && isSideViewGravity())
6817 781 return false;
6818
6819 532329 dy = dy1-s;
6820
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 532326 times.
532329 special = (special==spw_clipbottomright)?spw_none:special;
6821 532329 tries = usewid/(offgrid ? 8 : 16);
6822 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6823
2/2
✓ Branch 0 taken 459813 times.
✓ Branch 1 taken 532329 times.
992142 for ( ; tries > 0; --tries )
6824 {
6825
2/2
✓ Branch 0 taken 71050 times.
✓ Branch 1 taken 461279 times.
532329 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
6826 532329 try_x += (offgrid ? 8 : 16);
6827
2/2
✓ Branch 0 taken 459813 times.
✓ Branch 1 taken 72516 times.
532329 if (!ok) break;
6828 459813 }
6829
2/2
✓ Branch 0 taken 459813 times.
✓ Branch 1 taken 72516 times.
532329 if(!ok) break;
6830
1/2
✓ Branch 0 taken 459813 times.
✗ Branch 1 not taken.
459813 if((usewid%16)>0) //Uneven width
6831 {
6832 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
6833 }
6834 459813 break;
6835 }
6836 case 12:
6837 case down:
6838 {
6839
4/4
✓ Branch 0 taken 106855 times.
✓ Branch 1 taken 319115 times.
✓ Branch 2 taken 105949 times.
✓ Branch 3 taken 906 times.
425970 if(enemycanfall(id) && isSideViewGravity())
6840 906 return false;
6841
6842 425064 dy = dy2+s;
6843 425064 tries = usewid/(offgrid ? 8 : 16);
6844 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
6845
2/2
✓ Branch 0 taken 349013 times.
✓ Branch 1 taken 425064 times.
774077 for ( ; tries > 0; --tries )
6846 {
6847
3/4
✓ Branch 0 taken 76001 times.
✓ Branch 1 taken 349063 times.
✓ Branch 2 taken 349063 times.
✗ Branch 3 not taken.
425064 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6848 425064 try_x += (offgrid ? 8 : 16);
6849
2/2
✓ Branch 0 taken 349013 times.
✓ Branch 1 taken 76051 times.
425064 if (!ok) break;
6850 349013 }
6851
2/2
✓ Branch 0 taken 349013 times.
✓ Branch 1 taken 76051 times.
425064 if(!ok) break;
6852
1/2
✓ Branch 0 taken 349013 times.
✗ Branch 1 not taken.
349013 if((usewid%16)>0) //Uneven width
6853 {
6854 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
6855 }
6856 349013 break;
6857 }
6858 case 14:
6859 case left:
6860 {
6861 472597 dx = dx1-s;
6862 472597 sv = ((isSideViewGravity())?7:0);
6863
4/4
✓ Branch 0 taken 472591 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1082 times.
✓ Branch 3 taken 471509 times.
472597 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
6864 472597 tries = usehei/(offgrid ? 8 : 16);
6865 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6866
2/2
✓ Branch 0 taken 401801 times.
✓ Branch 1 taken 472597 times.
874398 for ( ; tries > 0; --tries )
6867 {
6868
2/2
✓ Branch 0 taken 70372 times.
✓ Branch 1 taken 402225 times.
472597 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
6869 472597 try_y += (offgrid ? 8 : 16);
6870
2/2
✓ Branch 0 taken 401801 times.
✓ Branch 1 taken 70796 times.
472597 if (!ok) break;
6871 401801 }
6872
2/2
✓ Branch 0 taken 401801 times.
✓ Branch 1 taken 70796 times.
472597 if(!ok) break;
6873
1/2
✓ Branch 0 taken 401801 times.
✗ Branch 1 not taken.
401801 if((usehei%16)>0) //Uneven height
6874 {
6875 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
6876 }
6877 401801 break;
6878 }
6879 case 10:
6880 case right:
6881 {
6882 485200 dx = dx2+s;
6883 485200 sv = ((isSideViewGravity())?7:0);
6884 485200 tries = usehei/(offgrid ? 8 : 16);
6885 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
6886
2/2
✓ Branch 0 taken 415582 times.
✓ Branch 1 taken 485200 times.
900782 for ( ; tries > 0; --tries )
6887 {
6888
3/4
✓ Branch 0 taken 69211 times.
✓ Branch 1 taken 415989 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 415989 times.
485200 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
6889 485200 try_y += (offgrid ? 8 : 16);
6890
2/2
✓ Branch 0 taken 415582 times.
✓ Branch 1 taken 69618 times.
485200 if (!ok) break;
6891 415582 }
6892
2/2
✓ Branch 0 taken 415582 times.
✓ Branch 1 taken 69618 times.
485200 if(!ok) break;
6893
1/2
✓ Branch 0 taken 415582 times.
✗ Branch 1 not taken.
415582 if((usehei%16)>0) //Uneven height
6894 {
6895 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
6896 }
6897 415582 break;
6898 }
6899 case 9:
6900 case r_up:
6901 {
6902 223241 dx = dx2+s;
6903 223241 dy = dy1-s;
6904 223241 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6905 223241 sv = ((isSideViewGravity())?7:0);
6906
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 223241 times.
439080 for ( ; tries_x > 0; --tries_x )
6907 {
6908 223241 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6909 223241 try_y = 0;
6910
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 223241 times.
439080 for ( ; tries_y > 0; --tries_y )
6911 {
6912
4/4
✓ Branch 0 taken 220158 times.
✓ Branch 1 taken 3083 times.
✓ Branch 2 taken 217730 times.
✓ Branch 3 taken 2428 times.
440971 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6913
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 216286 times.
217730 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6914 223241 try_y += (offgrid ? 8 : 16);
6915
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 7402 times.
223241 if (!ok) break;
6916 215839 }
6917
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 7402 times.
223241 if (!ok) break;
6918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215839 times.
215839 if((usehei%16)>0) //Uneven height
6919 {
6920 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6921 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
6922 }
6923 215839 try_x += (offgrid ? 8 : 16);
6924 215839 }
6925
2/2
✓ Branch 0 taken 215839 times.
✓ Branch 1 taken 7402 times.
223241 if(!ok) break;
6926
1/2
✓ Branch 0 taken 215839 times.
✗ Branch 1 not taken.
215839 if((usewid%16)>0) //Uneven width
6927 {
6928 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6929 try_y = 0;
6930 for ( ; tries_y > 0; --tries_y )
6931 {
6932 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
6933 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
6934 try_y += (offgrid ? 8 : 16);
6935 if (!ok) break;
6936 }
6937 if (!ok) break;
6938 if((usehei%16)>0) //Uneven height
6939 {
6940 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
6941 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
6942 }
6943 }
6944 215839 break;
6945 }
6946 case 11:
6947 case r_down:
6948 {
6949 270134 dx = dx2+s;
6950 270134 dx = dy2+s;
6951 270134 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6952 //sv = ((isSideViewGravity())?7:0);
6953
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 270134 times.
534226 for ( ; tries_x > 0; --tries_x )
6954 {
6955 270134 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6956 270134 try_y = 0;
6957
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 270134 times.
534226 for ( ; tries_y > 0; --tries_y )
6958 {
6959
4/4
✓ Branch 0 taken 270010 times.
✓ Branch 1 taken 124 times.
✓ Branch 2 taken 264133 times.
✓ Branch 3 taken 5877 times.
534267 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
6960
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 264132 times.
264133 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
6961 270134 try_y += (offgrid ? 8 : 16);
6962
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 6042 times.
270134 if (!ok) break;
6963 264092 }
6964
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 6042 times.
270134 if (!ok) break;
6965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264092 times.
264092 if((usehei%16)>0) //Uneven height
6966 {
6967 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
6968 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
6969 }
6970 264092 try_x += (offgrid ? 8 : 16);
6971 264092 }
6972
2/2
✓ Branch 0 taken 264092 times.
✓ Branch 1 taken 6042 times.
270134 if(!ok) break;
6973
1/2
✓ Branch 0 taken 264092 times.
✗ Branch 1 not taken.
264092 if((usewid%16)>0) //Uneven width
6974 {
6975 int32_t tries_y = usehei/(offgrid ? 8 : 16);
6976 try_y = 0;
6977 for ( ; tries_y > 0; --tries_y )
6978 {
6979 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
6980 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
6981 try_y += (offgrid ? 8 : 16);
6982 if (!ok) break;
6983 }
6984 if (!ok) break;
6985 if((usehei%16)>0) //Uneven height
6986 {
6987 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
6988 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
6989 }
6990 }
6991 264092 break;
6992 }
6993 case 13:
6994 case l_down:
6995 {
6996 249156 dx = dx1-s;
6997 249156 dy = dy2+s;
6998 249156 int32_t tries_x = usewid/(offgrid ? 8 : 16);
6999 //sv = ((isSideViewGravity())?7:0);
7000
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 249156 times.
492078 for ( ; tries_x > 0; --tries_x )
7001 {
7002 249156 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7003 249156 try_y = 0;
7004
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 249156 times.
492078 for ( ; tries_y > 0; --tries_y )
7005 {
7006
4/4
✓ Branch 0 taken 244908 times.
✓ Branch 1 taken 4248 times.
✓ Branch 2 taken 242962 times.
✓ Branch 3 taken 1946 times.
492118 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7007
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 242931 times.
242962 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7008 249156 try_y += (offgrid ? 8 : 16);
7009
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 6234 times.
249156 if (!ok) break;
7010 242922 }
7011
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 6234 times.
249156 if (!ok) break;
7012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 242922 times.
242922 if((usehei%16)>0) //Uneven height
7013 {
7014 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7015 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7016 }
7017 242922 try_x += (offgrid ? 8 : 16);
7018 242922 }
7019
2/2
✓ Branch 0 taken 242922 times.
✓ Branch 1 taken 6234 times.
249156 if(!ok) break;
7020
1/2
✓ Branch 0 taken 242922 times.
✗ Branch 1 not taken.
242922 if((usewid%16)>0) //Uneven width
7021 {
7022 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7023 try_y = 0;
7024 for ( ; tries_y > 0; --tries_y )
7025 {
7026 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7027 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7028 try_y += (offgrid ? 8 : 16);
7029 if (!ok) break;
7030 }
7031 if (!ok) break;
7032 if((usehei%16)>0) //Uneven height
7033 {
7034 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7035 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7036 }
7037 }
7038 242922 break;
7039 }
7040 case 15:
7041 case l_up:
7042 {
7043 236113 dx = dx1-s;
7044 236113 dy = dy1-s;
7045 236113 int32_t tries_x = usewid/(offgrid ? 8 : 16);
7046 236113 sv = ((isSideViewGravity())?7:0);
7047
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 236113 times.
465238 for ( ; tries_x > 0; --tries_x )
7048 {
7049 236113 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7050 236113 try_y = 0;
7051
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 236113 times.
465238 for ( ; tries_y > 0; --tries_y )
7052 {
7053
4/4
✓ Branch 0 taken 232870 times.
✓ Branch 1 taken 3243 times.
✓ Branch 2 taken 231041 times.
✓ Branch 3 taken 1829 times.
467154 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
7054
2/2
✓ Branch 0 taken 1454 times.
✓ Branch 1 taken 229587 times.
231041 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
7055 236113 try_y += (offgrid ? 8 : 16);
7056
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 6988 times.
236113 if (!ok) break;
7057 229125 }
7058
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 6988 times.
236113 if (!ok) break;
7059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 229125 times.
229125 if((usehei%16)>0) //Uneven height
7060 {
7061 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
7062 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
7063 }
7064 229125 try_x += (offgrid ? 8 : 16);
7065 229125 }
7066
2/2
✓ Branch 0 taken 229125 times.
✓ Branch 1 taken 6988 times.
236113 if(!ok) break;
7067
1/2
✓ Branch 0 taken 229125 times.
✗ Branch 1 not taken.
229125 if((usewid%16)>0) //Uneven width
7068 {
7069 int32_t tries_y = usehei/(offgrid ? 8 : 16);
7070 try_y = 0;
7071 for ( ; tries_y > 0; --tries_y )
7072 {
7073 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
7074 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
7075 try_y += (offgrid ? 8 : 16);
7076 if (!ok) break;
7077 }
7078 if (!ok) break;
7079 if((usehei%16)>0) //Uneven height
7080 {
7081 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
7082 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
7083 }
7084 }
7085 229125 break;
7086 }
7087 default:
7088 124 db=99;
7089 124 return true;
7090 }
7091 //Z_eventlog("\n");
7092 2893834 return ok;
7093 2895645 }
7094
7095
7096 1892949 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
7097 {
7098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1892949 times.
1892949 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1892949 times.
1892949 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7100
1/2
✓ Branch 0 taken 1892949 times.
✗ Branch 1 not taken.
1892949 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7101
1/2
✓ Branch 0 taken 1892949 times.
✗ Branch 1 not taken.
1892949 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7102 1892949 --usewid;
7103 1892949 --usehei;
7104 1892949 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
7105 }
7106
7107 490232 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
7108 {
7109 490232 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
7110
7111
4/4
✓ Branch 0 taken 4058 times.
✓ Branch 1 taken 486174 times.
✓ Branch 2 taken 3033 times.
✓ Branch 3 taken 1025 times.
490232 if(special==spw_clipright&&ndir==right)
7112 {
7113 1025 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
7114 1025 }
7115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490232 times.
490232 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hxsz : 16;
7116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 490232 times.
490232 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hysz : 16;
7117
1/2
✓ Branch 0 taken 490232 times.
✗ Branch 1 not taken.
490232 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
7118
1/2
✓ Branch 0 taken 490232 times.
✗ Branch 1 not taken.
490232 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
7119 490232 --usewid;
7120 490232 --usehei;
7121
2/2
✓ Branch 0 taken 262241 times.
✓ Branch 1 taken 227991 times.
490232 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
7122 }
7123
7124 46098 bool enemy::canmove(int32_t ndir, bool kb)
7125 {
7126 46098 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
7127 }
7128
7129 // 8-directional
7130 349 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7131 {
7132 349 int32_t ndir=0;
7133
7134 // can move straight, check if it wants to turn
7135
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 8 times.
349 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
7136 {
7137
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
341 if(grumble && (zc_oldrand()&4)<grumble) //Homing
7138 {
7139 int32_t w = Lwpns.idFirst(wBait);
7140
7141 if(w>=0)
7142 {
7143 int32_t bx = Lwpns.spr(w)->x;
7144 int32_t by = Lwpns.spr(w)->y;
7145
7146 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7147
7148 if(abs(int32_t(y)-by)>14)
7149 {
7150 if(ndir>0) // Already left or right
7151 {
7152 // Making the diagonal directions
7153 ndir += (by<y) ? 2 : 4;
7154 }
7155 else
7156 {
7157 ndir = (by<y) ? up : down;
7158 }
7159 }
7160
7161 if(canmove(ndir,special,false))
7162 {
7163 dir=ndir;
7164 return;
7165 }
7166 }
7167 }
7168
7169 // Homing added.
7170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
341 if(newhoming && (zc_oldrand()&255)<newhoming)
7171 {
7172 ndir = lined_up(8,true);
7173
7174 if(ndir>=0 && canmove(ndir,special,false))
7175 {
7176 dir=ndir;
7177 }
7178
7179 return;
7180 }
7181
7182 341 int32_t r=zc_oldrand();
7183
7184
2/4
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 341 times.
341 if(newrate>0 && !(r%newrate))
7185 {
7186 341 ndir = ((dir+((r&64)?-1:1))&7)+8;
7187 341 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7188
7189
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 14 times.
341 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7190 327 dir=ndir;
7191
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7192 11 dir=ndir2;
7193
7194
3/4
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 327 times.
✗ Branch 3 not taken.
341 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7195 // due to numerous lost fractional components. -L
7196 {
7197 x.doFloor();
7198 y.doFloor();
7199 }
7200 341 }
7201
7202 341 return;
7203 }
7204
7205 // can't move straight, must turn
7206 8 int32_t i=0;
7207
7208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 for(; i<32; i++) // Try random dir
7209 {
7210 15 ndir=(zc_oldrand()&7)+8;
7211
7212
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 8 times.
15 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7213 8 break;
7214 7 }
7215
7216
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(i==32)
7217 {
7218 for(ndir=8; ndir<16; ndir++)
7219 {
7220 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7221 goto ok;
7222 }
7223
7224 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7225 }
7226
7227 ok:
7228 8 dir=ndir;
7229 8 x.doFloor();
7230 8 y.doFloor();
7231 349 }
7232
7233 238523 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
7234 {
7235 238523 int32_t ndir=0;
7236
7237 // can move straight, check if it wants to turn
7238
2/2
✓ Branch 0 taken 224518 times.
✓ Branch 1 taken 14005 times.
238523 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
7239 {
7240
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224518 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
224518 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
7241 {
7242 int32_t i = Lwpns.idFirst(wBait);
7243 if(i >= 0) //idfirst returns -1 if it can't find any
7244 {
7245 weapon *w = (weapon*)Lwpns.spr(i);
7246 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7247 {
7248 int32_t currentrange;
7249 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7250 else currentrange = -1;
7251 int curid = i;
7252 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7253 for(; i<Lwpns.Count(); ++i)
7254 {
7255 weapon *lw = (weapon*)Lwpns.spr(i);
7256 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7257 {
7258 currentrange = distance(x, y, lw->x, lw->y);
7259 curid = i;
7260 }
7261 }
7262 i = curid;
7263 if (currentrange == -1) i = -1;
7264 }
7265 else
7266 {
7267 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7268 }
7269 if(i>=0)
7270 {
7271 int32_t bx = Lwpns.spr(i)->x;
7272 int32_t by = Lwpns.spr(i)->y;
7273
7274 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
7275
7276 if(abs(int32_t(y)-by)>14)
7277 {
7278 if(ndir>0) // Already left or right
7279 {
7280 // Making the diagonal directions
7281 ndir += (by<y) ? 2 : 4;
7282 }
7283 else
7284 {
7285 ndir = (by<y) ? up : down;
7286 }
7287 }
7288 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7289 if(canmove(ndir,special,false))
7290 {
7291 dir=ndir;
7292 return;
7293 }
7294 }
7295 }
7296 }
7297
7298 // Homing added.
7299
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224518 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
224518 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
7300 {
7301 ndir = lined_up(8,true);
7302 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7303 if(ndir>=0 && canmove(ndir,special,false))
7304 {
7305 dir=ndir;
7306 }
7307
7308 return;
7309 }
7310
7311 224518 int32_t r=zc_oldrand();
7312
7313
4/4
✓ Branch 0 taken 149027 times.
✓ Branch 1 taken 75491 times.
✓ Branch 2 taken 79975 times.
✓ Branch 3 taken 69052 times.
224518 if(newrate>0 && !(r%newrate))
7314 {
7315 69052 ndir = ((dir+((r&64)?-1:1))&7)+8;
7316 69052 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
7317
7318
2/2
✓ Branch 0 taken 66852 times.
✓ Branch 1 taken 2200 times.
69052 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7319 66852 dir=ndir;
7320
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2195 times.
2200 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
7321 2195 dir=ndir2;
7322
7323
4/4
✓ Branch 0 taken 66852 times.
✓ Branch 1 taken 2200 times.
✓ Branch 2 taken 63828 times.
✓ Branch 3 taken 3024 times.
69052 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
7324 // due to numerous lost fractional components. -L
7325 {
7326 3024 x.doFloor();
7327 3024 y.doFloor();
7328 3024 }
7329 69052 }
7330
7331 224518 return;
7332 }
7333
7334 // can't move straight, must turn
7335 14005 int32_t i=0;
7336
7337
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 26101 times.
26111 for(; i<32; i++) // Try random dir
7338 {
7339 26101 ndir=(zc_oldrand()&7)+8;
7340
7341
2/2
✓ Branch 0 taken 12106 times.
✓ Branch 1 taken 13995 times.
26101 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7342 13995 break;
7343 12106 }
7344
7345
2/2
✓ Branch 0 taken 13995 times.
✓ Branch 1 taken 10 times.
14005 if(i==32)
7346 {
7347
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 for(ndir=8; ndir<16; ndir++)
7348 {
7349
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
12 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
7350 10 goto ok;
7351 2 }
7352
7353 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7354 }
7355
7356 ok:
7357 14005 dir=ndir;
7358 14005 x.doFloor();
7359 14005 y.doFloor();
7360 238523 }
7361
7362 235655 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
7363 {
7364 235655 newdir_8(newrate,newhoming,special,0,-8,15,15);
7365 235655 }
7366
7367 349 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
7368 {
7369 349 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
7370 349 }
7371
7372 // makes the enemy slide backwards when hit
7373 // sclk: first byte is clk, second byte is dir
7374 // makes the enemy slide backwards when hit
7375 // sclk: first byte is clk, second byte is dir
7376 6855408 int32_t enemy::slide()
7377 {
7378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6855408 times.
6855408 if(script_knockback_clk!=0) //scripted knockback
7379 {
7380 sclk = 0;
7381 return 1; //scripted knockback ran
7382 }
7383
5/6
✓ Branch 0 taken 43774 times.
✓ Branch 1 taken 6811634 times.
✓ Branch 2 taken 5087 times.
✓ Branch 3 taken 38687 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5087 times.
6855408 if(sclk==0 || (hp<=0 && !immortal))
7384 6816721 return 0;
7385
7386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38687 times.
38687 if(knockbackflags & FLAG_NOSLIDE)
7387 {
7388 sclk = 0;
7389 if(!OFFGRID_ENEMY)
7390 {
7391 //Fix to grid
7392 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
7393 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
7394 do_fix(x, 16, true);
7395 do_fix(y, 16, true);
7396 }
7397 return 0;
7398 }
7399
8/10
✓ Branch 0 taken 3954 times.
✓ Branch 1 taken 34733 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 3929 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 2917 times.
✓ Branch 7 taken 1012 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
38687 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
7400 {
7401 1012 sclk=0;
7402 1012 return 0;
7403 }
7404
7405 37675 --sclk;
7406
7407
5/5
✓ Branch 0 taken 1403 times.
✓ Branch 1 taken 4257 times.
✓ Branch 2 taken 4583 times.
✓ Branch 3 taken 12580 times.
✓ Branch 4 taken 14852 times.
37675 switch(sclk>>8)
7408 {
7409 case up:
7410 {
7411
4/4
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 3826 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 4251 times.
4257 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
7412 {
7413 6 sclk=0;
7414 6 return 0;
7415 }
7416
4/4
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 3820 times.
✓ Branch 2 taken 365 times.
✓ Branch 3 taken 66 times.
4251 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7417
7418 4185 break;
7419 }
7420 case down:
7421 {
7422
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4581 times.
4583 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
7423 {
7424 2 sclk=0;
7425 2 return 0;
7426 }
7427
4/4
✓ Branch 0 taken 581 times.
✓ Branch 1 taken 4000 times.
✓ Branch 2 taken 502 times.
✓ Branch 3 taken 79 times.
4581 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7428
7429 4502 break;
7430 }
7431 case left:
7432 {
7433
4/4
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 11573 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 12567 times.
12580 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
7434 {
7435 13 sclk=0;
7436 13 return 0;
7437 }
7438
4/4
✓ Branch 0 taken 1007 times.
✓ Branch 1 taken 11560 times.
✓ Branch 2 taken 920 times.
✓ Branch 3 taken 87 times.
12567 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
7439
7440 12480 break;
7441 }
7442 case right:
7443 {
7444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14852 times.
14852 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
7445 {
7446 sclk=0;
7447 return 0;
7448 }
7449
4/4
✓ Branch 0 taken 1959 times.
✓ Branch 1 taken 12893 times.
✓ Branch 2 taken 1826 times.
✓ Branch 3 taken 133 times.
14852 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
7450 14719 break;
7451 }
7452 }
7453
7454 37289 int32_t move = knockbackSpeed;
7455
2/2
✓ Branch 0 taken 35367 times.
✓ Branch 1 taken 37289 times.
72656 while(move>0)
7456 {
7457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37289 times.
37289 int32_t thismove = zc_min(8, move);
7458 37289 move -= thismove;
7459 37289 hitdir = (sclk>>8);
7460
5/5
✓ Branch 0 taken 1403 times.
✓ Branch 1 taken 4185 times.
✓ Branch 2 taken 4502 times.
✓ Branch 3 taken 12480 times.
✓ Branch 4 taken 14719 times.
37289 switch(sclk>>8)
7461 {
7462 case up:
7463 4185 y-=thismove;
7464 4185 break;
7465
7466 case down:
7467 4502 y+=thismove;
7468 4502 break;
7469
7470 case left:
7471 12480 x-=thismove;
7472 12480 break;
7473
7474 case right:
7475 14719 x+=thismove;
7476 14719 break;
7477 }
7478
2/2
✓ Branch 0 taken 35367 times.
✓ Branch 1 taken 1922 times.
37289 if(!canmove(sclk>>8,(zfix)0,0,true))
7479 {
7480
3/3
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 1165 times.
✓ Branch 2 taken 3 times.
1922 switch(sclk>>8)
7481 {
7482 case up:
7483 case down:
7484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 754 times.
754 if(y < 0)
7485 y = 0;
7486
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 615 times.
754 else if((int32_t(y)&15) > 7)
7487 139 y=(int32_t(y)&0xF0)+16;
7488 else
7489 615 y=(int32_t(y)&0xF0);
7490
7491 754 break;
7492
7493 case left:
7494 case right:
7495
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1164 times.
1165 if(x < 0)
7496 1 x = 0;
7497
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 825 times.
1164 else if((int32_t(x)&15) > 7)
7498 339 x=(int32_t(x)&0xF0)+16;
7499 else
7500 825 x=(int32_t(x)&0xF0);
7501
7502 1165 break;
7503 }
7504
7505 1922 sclk=0;
7506 1922 clk3=0;
7507 1922 break;
7508 }
7509 }
7510
7511
2/2
✓ Branch 0 taken 34371 times.
✓ Branch 1 taken 2918 times.
37289 if((sclk&255)==0)
7512 {
7513 //hitdir = -1;
7514 2918 sclk=0;
7515 2918 }
7516 37289 return 2;
7517 6855408 }
7518
7519 bool enemy::can_slide()
7520 {
7521 if(sclk==0 || (hp<=0 && !immortal))
7522 return false;
7523
7524 if((sclk&255)==16 && (get_bit(quest_rules,qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
7525 {
7526 return false;
7527 }
7528
7529 return true;
7530 }
7531
7532 bool enemy::fslide()
7533 {
7534 if(sclk==0 || (hp<=0 && !immortal))
7535 return false;
7536
7537 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
7538 {
7539 sclk=0;
7540 return false;
7541 }
7542
7543 --sclk;
7544
7545 switch(sclk>>8)
7546 {
7547 case up:
7548 if(y<=16)
7549 {
7550 sclk=0;
7551 return false;
7552 }
7553
7554 break;
7555
7556 case down:
7557 if(y>=160)
7558 {
7559 sclk=0;
7560 return false;
7561 }
7562
7563 break;
7564
7565 case left:
7566 if(x<=16)
7567 {
7568 sclk=0;
7569 return false;
7570 }
7571
7572 break;
7573
7574 case right:
7575 if(x>=240)
7576 {
7577 sclk=0;
7578 return false;
7579 }
7580
7581 break;
7582 }
7583 hitdir = (sclk>>8);
7584 switch(sclk>>8)
7585 {
7586 case up:
7587 y-=4;
7588 break;
7589
7590 case down:
7591 y+=4;
7592 break;
7593
7594 case left:
7595 x-=4;
7596 break;
7597
7598 case right:
7599 x+=4;
7600 break;
7601 }
7602
7603 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
7604 {
7605 switch(sclk>>8)
7606 {
7607 case up:
7608 case down:
7609 if((int32_t(y)&15) > 7)
7610 y=(int32_t(y)&0xF0)+16;
7611 else
7612 y=(int32_t(y)&0xF0);
7613
7614 break;
7615
7616 case left:
7617 case right:
7618 if((int32_t(x)&15) > 7)
7619 x=(int32_t(x)&0xF0)+16;
7620 else
7621 x=(int32_t(x)&0xF0);
7622
7623 break;
7624 }
7625
7626 sclk=0;
7627 clk3=0;
7628 }
7629
7630 if((sclk&255)==0)
7631 sclk=0;
7632
7633 return true;
7634 }
7635
7636 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
7637 {
7638 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
7639 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
7640 bool ret = sprite::knockback(time, dir, speed);
7641 if(ret) sclk = 0; //kill engine knockback if interrupted
7642 //! Perhaps also set hitdir here, if needed for timing? -Z
7643 return ret;
7644 }
7645
7646 15718848 bool enemy::runKnockback()
7647 {
7648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15718848 times.
15718848 if((script_knockback_clk&0xFF)==0)
7649 {
7650 15718848 script_knockback_clk = 0;
7651 15718848 return false;
7652 }
7653 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
7654 {
7655 return false;
7656 }
7657 int32_t move = script_knockback_speed;
7658 int32_t kb_dir = script_knockback_clk>>8;
7659 --script_knockback_clk;
7660
7661 while(move>0)
7662 {
7663 int32_t thismove = zc_min(get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
7664 move -= thismove;
7665 hitdir = kb_dir;
7666 switch(kb_dir)
7667 {
7668 case r_up:
7669 case l_up:
7670 case up:
7671 y-=thismove;
7672 break;
7673
7674 case r_down:
7675 case l_down:
7676 case down:
7677 y+=thismove;
7678 break;
7679 }
7680 switch(kb_dir)
7681 {
7682 case l_up:
7683 case l_down:
7684 case left:
7685 x-=thismove;
7686 break;
7687
7688 case r_up:
7689 case r_down:
7690 case right:
7691 x+=thismove;
7692 break;
7693 }
7694 if (get_bit(quest_rules, qr_OLD_SCRIPTED_KNOCKBACK))
7695 {
7696 if(!canmove(kb_dir,(zfix)0,0,true))
7697 {
7698 script_knockback_clk=0;
7699 clk3=0;
7700 //Fix to grid
7701 switch(kb_dir)
7702 {
7703 case up:
7704 case down:
7705 break;
7706 default:
7707 if(x < 0)
7708 x = 0;
7709 else if((int32_t(x)&15) > 7)
7710 x=(int32_t(x)&0xF0)+16;
7711 else
7712 x=(int32_t(x)&0xF0);
7713 break;
7714 }
7715 switch(kb_dir)
7716 {
7717 case left:
7718 case right:
7719 break;
7720 default:
7721 if(y < 0)
7722 y = 0;
7723 else if((int32_t(y)&15) > 7)
7724 y=(int32_t(y)&0xF0)+16;
7725 else
7726 y=(int32_t(y)&0xF0);
7727 break;
7728 }
7729 break;
7730 }
7731 }
7732 else
7733 {
7734 if(!scr_canplace(x,y,0,true))
7735 {
7736 script_knockback_clk=0;
7737 clk3=0;
7738 //Fix to grid
7739 if (OFFGRID_ENEMY)
7740 {
7741 switch(kb_dir)
7742 {
7743 case up:
7744 case down:
7745 break;
7746 default:
7747 if(x < 0)
7748 x = 0;
7749 else if((int32_t(x)&7) > 3)
7750 x=(int32_t(x)&0xF8)+8;
7751 else
7752 x=(int32_t(x)&0xF8);
7753 break;
7754 }
7755 switch(kb_dir)
7756 {
7757 case left:
7758 case right:
7759 break;
7760 default:
7761 if(y < 0)
7762 y = 0;
7763 else if((int32_t(y)&7) > 3)
7764 y=(int32_t(y)&0xF8)+8;
7765 else
7766 y=(int32_t(y)&0xF8);
7767 break;
7768 }
7769 }
7770 else
7771 {
7772 switch(kb_dir)
7773 {
7774 case up:
7775 case down:
7776 break;
7777 default:
7778 if(x < 0)
7779 x = 0;
7780 else if((int32_t(x)&15) > 7)
7781 x=(int32_t(x)&0xF0)+16;
7782 else
7783 x=(int32_t(x)&0xF0);
7784 break;
7785 }
7786 switch(kb_dir)
7787 {
7788 case left:
7789 case right:
7790 break;
7791 default:
7792 if(y < 0)
7793 y = 0;
7794 else if((int32_t(y)&15) > 7)
7795 y=(int32_t(y)&0xF0)+16;
7796 else
7797 y=(int32_t(y)&0xF0);
7798 break;
7799 }
7800 }
7801 break;
7802 }
7803
7804 }
7805 }
7806 return true;
7807 15718848 }
7808 // changes enemy's direction, checking restrictions
7809 // rate: 0 = no random changes, 16 = always random change
7810 // homing: 0 = none, 256 = always
7811 // grumble 0 = none, 4 = strongest appetite
7812 227955 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
7813 {
7814 227955 int32_t ndir=-1;
7815
7816
4/4
✓ Branch 0 taken 46772 times.
✓ Branch 1 taken 181183 times.
✓ Branch 2 taken 17331 times.
✓ Branch 3 taken 29441 times.
227955 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
7817 {
7818 29441 int32_t i = Lwpns.idFirst(wBait);
7819
1/2
✓ Branch 0 taken 29441 times.
✗ Branch 1 not taken.
29441 if(i >= 0) //idfirst returns -1 if it can't find any
7820 {
7821 weapon *w = (weapon*)Lwpns.spr(i);
7822 if (get_bit(quest_rules, qr_FIND_CLOSEST_BAIT))
7823 {
7824 int32_t currentrange;
7825 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
7826 else currentrange = -1;
7827 int curid = i;
7828 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
7829 for(; i<Lwpns.Count(); ++i)
7830 {
7831 weapon *lw = (weapon*)Lwpns.spr(i);
7832 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
7833 {
7834 currentrange = distance(x, y, lw->x, lw->y);
7835 curid = i;
7836 }
7837 }
7838 i = curid;
7839 if (currentrange == -1) i = -1;
7840 }
7841 else
7842 {
7843 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
7844 }
7845 if (i >= 0)
7846 {
7847 int32_t bx = Lwpns.spr(i)->x;
7848 int32_t by = Lwpns.spr(i)->y;
7849
7850 if(abs(int32_t(y)-by)>14)
7851 {
7852 ndir = (by<y) ? up : down;
7853 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7854 if(canmove(ndir,special,false))
7855 {
7856 dir=ndir;
7857 return;
7858 }
7859 }
7860
7861 ndir = (bx<x) ? left : right;
7862 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
7863 if(canmove(ndir,special,false))
7864 {
7865 dir=ndir;
7866 return;
7867 }
7868 }
7869 }
7870 29441 }
7871
7872
2/2
✓ Branch 0 taken 156694 times.
✓ Branch 1 taken 71261 times.
227955 if((zc_oldrand()&255)<abs(newhoming))
7873 {
7874 71261 ndir = lined_up(8,false);
7875
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 71261 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
71261 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
7876
4/4
✓ Branch 0 taken 19140 times.
✓ Branch 1 taken 52121 times.
✓ Branch 2 taken 2535 times.
✓ Branch 3 taken 16605 times.
71261 if(ndir>=0 && canmove(ndir,special,false))
7877 {
7878 16605 dir=ndir;
7879 16605 return;
7880 }
7881 54656 }
7882
7883 211350 int32_t i=0;
7884
7885
2/2
✓ Branch 0 taken 974 times.
✓ Branch 1 taken 468220 times.
469194 for(; i<32; i++)
7886 {
7887 468220 int32_t r=zc_oldrand();
7888
7889
2/2
✓ Branch 0 taken 143575 times.
✓ Branch 1 taken 324645 times.
468220 if((r&15)<newrate)
7890 143575 ndir=(r>>4)&3;
7891 else
7892 324645 ndir=dir;
7893
7894
2/2
✓ Branch 0 taken 257844 times.
✓ Branch 1 taken 210376 times.
468220 if(canmove(ndir,special,false))
7895 210376 break;
7896 257844 }
7897
7898
2/2
✓ Branch 0 taken 210376 times.
✓ Branch 1 taken 974 times.
211733 if(i==32)
7899 {
7900
2/2
✓ Branch 0 taken 2872 times.
✓ Branch 1 taken 383 times.
3255 for(ndir=0; ndir<4; ndir++)
7901 {
7902
2/2
✓ Branch 0 taken 2281 times.
✓ Branch 1 taken 591 times.
2872 if(canmove(ndir,special,false))
7903 591 goto ok;
7904 2281 }
7905
7906
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 318 times.
383 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
7907 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
7908 383 }
7909
7910 ok:
7911 211350 dir = ndir;
7912 227955 }
7913
7914 769 void enemy::newdir()
7915 {
7916 769 newdir(4,0,spw_none);
7917 769 }
7918
7919 zfix enemy::distance_left()
7920 {
7921 int32_t a2=x.getInt();
7922 int32_t b2=y.getInt();
7923
7924 switch(dir)
7925 {
7926 case up:
7927 return (zfix)(b2&0xF);
7928
7929 case down:
7930 return (zfix)(16-(b2&0xF));
7931
7932 case left:
7933 return (zfix)(a2&0xF);
7934
7935 case right:
7936 return (zfix)(16-(a2&0xF));
7937 }
7938
7939 return (zfix)0;
7940 }
7941
7942 // keeps walking around
7943 162919 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
7944 {
7945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 162919 times.
162919 if(slide())
7946 return;
7947
7948
8/12
✓ Branch 0 taken 161055 times.
✓ Branch 1 taken 1864 times.
✓ Branch 2 taken 161055 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159621 times.
✓ Branch 5 taken 1434 times.
✓ Branch 6 taken 159621 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 159621 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 159621 times.
162919 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
7949 3298 return;
7950
7951
2/2
✓ Branch 0 taken 9733 times.
✓ Branch 1 taken 149888 times.
159621 if(clk3<=0)
7952 {
7953 9733 fix_coords(true);
7954 9733 newdir(newrate,newhoming,special);
7955
7956
1/2
✓ Branch 0 taken 9733 times.
✗ Branch 1 not taken.
9733 if(step==0)
7957 clk3=0;
7958 else
7959 9733 clk3=int32_t(16.0/step);
7960 9733 }
7961
2/2
✓ Branch 0 taken 149870 times.
✓ Branch 1 taken 18 times.
149888 else if(scored)
7962 {
7963 18 dir^=1;
7964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (step != 0) clk3=int32_t(16.0/step)-clk3;
7965 else clk3=32767;
7966 18 }
7967
7968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159621 times.
159621 if (step != 0) --clk3;
7969 159621 move(step);
7970 162919 }
7971
7972 void enemy::constant_walk()
7973 {
7974 constant_walk(4,0,spw_none);
7975 }
7976
7977 11490 int32_t enemy::pos(int32_t newx,int32_t newy)
7978 {
7979 11490 return (newy<<8)+newx;
7980 }
7981
7982 // for variable step rates
7983 163339 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
7984 {
7985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 163339 times.
163339 if(slide())
7986 return;
7987
7988
10/14
✓ Branch 0 taken 163339 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 163339 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159369 times.
✓ Branch 5 taken 3970 times.
✓ Branch 6 taken 154093 times.
✓ Branch 7 taken 5276 times.
✓ Branch 8 taken 137258 times.
✓ Branch 9 taken 16835 times.
✓ Branch 10 taken 137258 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 137258 times.
✗ Branch 13 not taken.
163339 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
7989 26081 return;
7990
7991 137258 zfix dx = (zfix)0;
7992 137258 zfix dy = (zfix)0;
7993
7994
4/9
✓ Branch 0 taken 30088 times.
✓ Branch 1 taken 32107 times.
✓ Branch 2 taken 37170 times.
✓ Branch 3 taken 37893 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
137258 switch(dir)
7995 {
7996 case 8:
7997 case up:
7998 30088 dy-=step;
7999 30088 break;
8000
8001 case 12:
8002 case down:
8003 32107 dy+=step;
8004 32107 break;
8005
8006 case 14:
8007 case left:
8008 37170 dx-=step;
8009 37170 break;
8010
8011 case 10:
8012 case right:
8013 37893 dx+=step;
8014 37893 break;
8015
8016 case 15:
8017 case l_up:
8018 dx-=step;
8019 dy-=step;
8020 break;
8021
8022 case 9:
8023 case r_up:
8024 dx+=step;
8025 dy-=step;
8026 break;
8027
8028 case 13:
8029 case l_down:
8030 dx-=step;
8031 dy+=step;
8032 break;
8033
8034 case 11:
8035 case r_down:
8036 dx+=step;
8037 dy+=step;
8038 break;
8039 }
8040
8041
8/8
✓ Branch 0 taken 65961 times.
✓ Branch 1 taken 71297 times.
✓ Branch 2 taken 7132 times.
✓ Branch 3 taken 58829 times.
✓ Branch 4 taken 3793 times.
✓ Branch 5 taken 3339 times.
✓ Branch 6 taken 132900 times.
✓ Branch 7 taken 4358 times.
137258 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
8042 133465 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
8043 {
8044 4358 fix_coords();
8045 4358 newdir(newrate,newhoming,special);
8046 4358 clk3=pos(x,y);
8047 4358 }
8048
8049 137258 move(step);
8050 163339 }
8051
8052 // pauses for a while after it makes a complete move (to a new square)
8053 5528559 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
8054 {
8055
4/4
✓ Branch 0 taken 32445 times.
✓ Branch 1 taken 5496114 times.
✓ Branch 2 taken 25635 times.
✓ Branch 3 taken 6810 times.
5528559 if(sclk && clk2)
8056 {
8057 6810 clk3=0;
8058 6810 }
8059
8060
11/14
✓ Branch 0 taken 5500754 times.
✓ Branch 1 taken 27805 times.
✓ Branch 2 taken 5500754 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5500754 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5294128 times.
✓ Branch 7 taken 206626 times.
✓ Branch 8 taken 5188263 times.
✓ Branch 9 taken 105865 times.
✓ Branch 10 taken 5186491 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 5186491 times.
5528559 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8061 {
8062 342068 return;
8063 }
8064
8065
2/2
✓ Branch 0 taken 1071058 times.
✓ Branch 1 taken 4115433 times.
5186491 if(clk2>0)
8066 {
8067 1071058 --clk2;
8068 1071058 return;
8069 }
8070
8071
2/2
✓ Branch 0 taken 183299 times.
✓ Branch 1 taken 3932134 times.
4115433 if(clk3<=0)
8072 {
8073 183299 fix_coords(true);
8074 183299 newdir(newrate,newhoming,special);
8075 183299 clk3=int32_t(16.0/step);
8076
2/2
✓ Branch 0 taken 183291 times.
✓ Branch 1 taken 8 times.
183299 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
8077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 183299 times.
183299 if(clk2<0)
8078 {
8079 clk2=0;
8080 }
8081
2/2
✓ Branch 0 taken 25252 times.
✓ Branch 1 taken 158047 times.
183299 else if((zc_oldrand()&15)<newhrate)
8082 {
8083 25252 clk2=haltcnt;
8084 25252 return;
8085 }
8086 158047 }
8087
2/2
✓ Branch 0 taken 3931081 times.
✓ Branch 1 taken 1053 times.
3932134 else if(scored)
8088 {
8089 1053 dir^=1;
8090
8091
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1052 times.
1053 if (step != 0) clk3=int32_t(16.0/step)-clk3;
8092 1 else clk3=32767;
8093 1053 }
8094
8095
2/2
✓ Branch 0 taken 11925 times.
✓ Branch 1 taken 4078256 times.
4090181 if (step != 0) --clk3;
8096 4090181 move(step);
8097 5528559 }
8098
8099 // 8-directional movement, aligns to 8 pixels
8100 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
8101 {
8102 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8103 return;
8104
8105 if(clk3<=0)
8106 {
8107 newdir_8(newrate,newhoming,special);
8108 clk3=int32_t(8.0/step);
8109 if (step == 0) clk3 = 32767;
8110 }
8111
8112 if (step != 0) --clk3;
8113 move(step);
8114 }
8115 // 8-directional movement, aligns to 8 pixels
8116 74245 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
8117 {
8118
6/12
✓ Branch 0 taken 74245 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74245 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 74245 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 74245 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 74245 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 74245 times.
74245 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8119 return;
8120
8121
2/2
✓ Branch 0 taken 68773 times.
✓ Branch 1 taken 5472 times.
74245 if(clk3<=0)
8122 {
8123 5472 newdir_8(newrate,newhoming,special);
8124 5472 clk3=int32_t(8.0/step);
8125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if (step == 0) clk3 = 32767;
8126 5472 }
8127
8128
1/2
✓ Branch 0 taken 74245 times.
✗ Branch 1 not taken.
74245 if (step != 0) --clk3;
8129 74245 move(step);
8130 74245 }
8131
8132 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
8133 {
8134 if(clk<0 || dying || stunclk || watch || frozenclock)
8135 return;
8136
8137 if(!canmove(dir,step,special,false))
8138 clk3=0;
8139
8140 if(clk2>0)
8141 {
8142 --clk2;
8143 return;
8144 }
8145
8146 if(clk3<=0)
8147 {
8148 newdir_8(newrate,newhoming,special);
8149 clk3=newclk;
8150
8151 if(clk2<0)
8152 {
8153 clk2=0;
8154 }
8155 else if((zc_oldrand()&15)<newhrate)
8156 {
8157 newdir_8(newrate,newhoming,special);
8158 clk2=haltcnt;
8159 return;
8160 }
8161 }
8162
8163 --clk3;
8164 move(step);
8165 }
8166
8167 // 8-directional movement, no alignment
8168 1919681 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
8169 {
8170
9/12
✓ Branch 0 taken 1844558 times.
✓ Branch 1 taken 75123 times.
✓ Branch 2 taken 1844558 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1826436 times.
✓ Branch 5 taken 18122 times.
✓ Branch 6 taken 1819894 times.
✓ Branch 7 taken 6542 times.
✓ Branch 8 taken 1819894 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1819894 times.
1919681 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8171 99787 return;
8172
8173
2/2
✓ Branch 0 taken 1806758 times.
✓ Branch 1 taken 13136 times.
1819894 if(!canmove(dir,step,special,false))
8174 13136 clk3=0;
8175
8176
2/2
✓ Branch 0 taken 1589711 times.
✓ Branch 1 taken 230183 times.
1819894 if(clk3<=0)
8177 {
8178 230183 newdir_8(newrate,newhoming,special);
8179 230183 clk3=newclk;
8180 230183 }
8181
8182 1819894 --clk3;
8183 1819894 move(step);
8184 1919681 }
8185
8186 // same as above but with variable enemy size
8187 42942 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
8188 {
8189
8/12
✓ Branch 0 taken 42394 times.
✓ Branch 1 taken 548 times.
✓ Branch 2 taken 42394 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 42394 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 42343 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 42343 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 42343 times.
42942 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
8190 599 return;
8191
8192
2/2
✓ Branch 0 taken 41867 times.
✓ Branch 1 taken 476 times.
42343 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
8193 476 clk3=0;
8194
8195
2/2
✓ Branch 0 taken 39475 times.
✓ Branch 1 taken 2868 times.
42343 if(clk3<=0)
8196 {
8197 2868 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
8198 2868 clk3=newclk;
8199 2868 }
8200
8201 42343 --clk3;
8202 42343 move(step);
8203 42942 }
8204
8205 // the variable speed floater movement
8206 // ms is max speed
8207 // ss is step speed
8208 // s is step count
8209 // p is pause count
8210 // g is graduality :)
8211 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
8212 1588819 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8213 {
8214 1588819 ++clk2;
8215 1588819 byte over_pit = overpit(this);
8216
8217
4/4
✓ Branch 0 taken 408682 times.
✓ Branch 1 taken 1180137 times.
✓ Branch 2 taken 408415 times.
✓ Branch 3 taken 267 times.
1588819 if(dmisc1 && over_pit) p = 0;
8218
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 30408 times.
✓ Branch 2 taken 573151 times.
✓ Branch 3 taken 919072 times.
✓ Branch 4 taken 66188 times.
1588819 switch(movestatus)
8219 {
8220 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
8221 //! if the conditions prevent it, we jump back to case 2.
8222 case 0: // paused
8223
2/2
✓ Branch 0 taken 29779 times.
✓ Branch 1 taken 629 times.
30408 if(clk2>=p)
8224 {
8225 629 movestatus=1;
8226 629 clk2=0;
8227 629 }
8228
8229 30408 break;
8230
8231 case 1: // speeding up
8232
1/2
✓ Branch 0 taken 573151 times.
✗ Branch 1 not taken.
573151 if (s >= 0)
8233 {
8234
2/2
✓ Branch 0 taken 568955 times.
✓ Branch 1 taken 4196 times.
573151 if(clk2<g*s)
8235 {
8236
2/2
✓ Branch 0 taken 532547 times.
✓ Branch 1 taken 36408 times.
568955 if(!((clk2-1)%g))
8237 36408 step+=ss;
8238 568955 }
8239 else
8240 {
8241 4196 movestatus=2;
8242 4196 clk2=0;
8243 }
8244 573151 }
8245 else
8246 {
8247 if(step < ms)
8248 {
8249 if(!((clk2-1)%g))
8250 {
8251 step+=ss;
8252 if (step >= ms) step = ms;
8253 }
8254 }
8255 else
8256 {
8257 step = ms;
8258 movestatus=2;
8259 clk2=0;
8260 }
8261 }
8262
8263 573151 break;
8264
8265 case 2: // normal
8266 919072 step=ms;
8267
8268
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 919072 times.
✓ Branch 2 taken 181371 times.
✓ Branch 3 taken 737701 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 737701 times.
✓ Branch 6 taken 736716 times.
✓ Branch 7 taken 985 times.
919072 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
8269 {
8270
1/2
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
985 if (s >= 0) step=ss*s;
8271 else step=ms;
8272 985 movestatus=3;
8273 985 clk2=0;
8274 985 }
8275
8276 919072 break;
8277
8278 case 3: // slowing down
8279
1/2
✓ Branch 0 taken 66188 times.
✗ Branch 1 not taken.
66188 if (s >= 0)
8280 {
8281
2/2
✓ Branch 0 taken 65463 times.
✓ Branch 1 taken 725 times.
66188 if(clk2<=g*s)
8282 {
8283 { //don't slow down over pits
8284
8285
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 65451 times.
65463 if(over_pit)
8286 {
8287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
8288 {
8289 step=ms;
8290 }
8291 12 }
8292 else //can slow down
8293 {
8294
4/4
✓ Branch 0 taken 4078 times.
✓ Branch 1 taken 61373 times.
✓ Branch 2 taken 3816 times.
✓ Branch 3 taken 262 times.
65451 if(!(clk2%g) && !dmisc1)
8295 3816 step-=ss;
8296 }
8297 }
8298
8299
8300 65463 }
8301 else
8302 {
8303 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8304 //this doesn't help keese, as they have a z of 0.
8305 //they always nee to run this check.
8306 {
8307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 725 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
725 if(over_pit &&!dmisc1)
8308 {
8309 --clk2; //if over a pit, don't land, and revert clock change
8310 }
8311 else //can land safely
8312 {
8313 725 movestatus=0;
8314
3/4
✓ Branch 0 taken 445 times.
✓ Branch 1 taken 280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 445 times.
725 if(dmisc1&&!over_pit)
8315 445 step=0;
8316 725 clk2=0;
8317 }
8318 }
8319
8320 }
8321 66188 }
8322 else
8323 {
8324 if(step > 0)
8325 {
8326 if(over_pit)
8327 {
8328 if(dmisc1)
8329 {
8330 step=ms;
8331 }
8332 }
8333 else //can slow down
8334 {
8335 if(!(clk2%g))
8336 step-=ss;
8337 }
8338 }
8339 else
8340 {
8341 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
8342 //this doesn't help keese, as they have a z of 0.
8343 //they always nee to run this check.
8344 if(over_pit)
8345 {
8346 step+=ss; //if over a pit, don't land, and revert clock change
8347 }
8348 else //can land safely
8349 {
8350 movestatus=0;
8351 step=0;
8352 clk2=0;
8353 }
8354 }
8355 }
8356
8357 66188 break;
8358 }
8359
8360
2/2
✓ Branch 0 taken 922283 times.
✓ Branch 1 taken 666536 times.
1588819 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
8361 1588819 }
8362
8363 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
8364 {
8365 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
8366 }
8367
8368 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
8369 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
8370 383477 int32_t enemy::lined_up(int32_t range, bool dir8)
8371 {
8372 383477 int32_t lx = Hero.getX();
8373 383477 int32_t ly = Hero.getY();
8374
8375
2/2
✓ Branch 0 taken 14949 times.
✓ Branch 1 taken 368528 times.
383477 if(abs(lx-int32_t(x))<=range)
8376 {
8377
2/2
✓ Branch 0 taken 5775 times.
✓ Branch 1 taken 9174 times.
14949 if(ly<y)
8378 {
8379 5775 return up;
8380 }
8381
8382 9174 return down;
8383 }
8384
8385
2/2
✓ Branch 0 taken 17649 times.
✓ Branch 1 taken 350879 times.
368528 if(abs(ly-int32_t(y))<=range)
8386 {
8387
2/2
✓ Branch 0 taken 8750 times.
✓ Branch 1 taken 8899 times.
17649 if(lx<x)
8388 {
8389 8750 return left;
8390 }
8391
8392 8899 return right;
8393 }
8394
8395
2/2
✓ Branch 0 taken 69109 times.
✓ Branch 1 taken 281770 times.
350879 if(dir8)
8396 {
8397
2/2
✓ Branch 0 taken 96658 times.
✓ Branch 1 taken 185112 times.
281770 if(abs(lx-x)-abs(ly-y)<=range)
8398 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
8399 {
8400
2/2
✓ Branch 0 taken 42725 times.
✓ Branch 1 taken 53933 times.
96658 if(ly<y)
8401 {
8402
2/2
✓ Branch 0 taken 24747 times.
✓ Branch 1 taken 17978 times.
42725 if(lx<x)
8403 {
8404 24747 return l_up;
8405 }
8406 else
8407 {
8408 17978 return r_up;
8409 }
8410 }
8411 else
8412 {
8413
2/2
✓ Branch 0 taken 27282 times.
✓ Branch 1 taken 26651 times.
53933 if(lx<x)
8414 {
8415 26651 return l_down;
8416 }
8417 else
8418 {
8419 27282 return r_down;
8420 }
8421 }
8422 }
8423 185112 }
8424
8425 254221 return -1;
8426 383477 }
8427
8428 // returns true if Hero is within 'range' pixels of the enemy
8429 12998 bool enemy::HeroInRange(int32_t range)
8430 {
8431 12998 int32_t lx = Hero.getX();
8432 12998 int32_t ly = Hero.getY();
8433
2/2
✓ Branch 0 taken 10857 times.
✓ Branch 1 taken 2141 times.
12998 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
8434 }
8435
8436 // place the enemy in line with Hero (red wizzrobes)
8437 1871 void enemy::place_on_axis(bool floater, bool solid_ok)
8438 {
8439
6/6
✓ Branch 0 taken 1543 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 1700 times.
✓ Branch 3 taken 171 times.
✓ Branch 4 taken 1372 times.
✓ Branch 5 taken 328 times.
1871 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
8440
6/6
✓ Branch 0 taken 1557 times.
✓ Branch 1 taken 314 times.
✓ Branch 2 taken 1612 times.
✓ Branch 3 taken 259 times.
✓ Branch 4 taken 1298 times.
✓ Branch 5 taken 314 times.
1871 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
8441 1871 int32_t pos2=zc_oldrand()%23;
8442 1871 int32_t tried=0;
8443 1871 bool last_resort,placed=false;
8444
8445
8446 1871 do
8447 {
8448
2/2
✓ Branch 0 taken 1845 times.
✓ Branch 1 taken 1317 times.
3162 if(pos2<14)
8449 {
8450 1845 x=(pos2<<4)+16;
8451 1845 y=ly;
8452 1845 }
8453 else
8454 {
8455 1317 x=lx;
8456 1317 y=((pos2-14)<<4)+16;
8457 }
8458
8459 // Don't commit to a last resort if position is out of bounds.
8460
6/6
✓ Branch 0 taken 3040 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 2914 times.
✓ Branch 3 taken 126 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2820 times.
3162 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
8461
8462
4/4
✓ Branch 0 taken 1637 times.
✓ Branch 1 taken 1525 times.
✓ Branch 2 taken 2777 times.
✓ Branch 3 taken 1658 times.
3162 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
8463 {
8464 // Red Wizzrobes should be able to appear on water, but not other
8465 // solid combos; however, they could appear on solid combos in 2.10,
8466 // and some quests depend on that.
8467
4/4
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 2846 times.
✓ Branch 2 taken 975 times.
✓ Branch 3 taken 1871 times.
4302 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
8468 4302 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
8469 1871 placed=true;
8470 4302 }
8471
8472
3/6
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 2855 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1291 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4146 if(!placed && tried>=22 && last_resort)
8473 {
8474 placed=true;
8475 }
8476
8477 4146 ++tried;
8478 4146 pos2=(pos2+3)%23;
8479
2/2
✓ Branch 0 taken 1291 times.
✓ Branch 1 taken 2855 times.
4146 }
8480 4146 while(!placed);
8481
8482
2/2
✓ Branch 0 taken 2157 times.
✓ Branch 1 taken 698 times.
2855 if(y==ly)
8483 2157 dir=(x<lx)?right:left;
8484 else
8485 698 dir=(y<ly)?down:up;
8486
8487 2855 clk2=tried;
8488 2855 }
8489
8490 8749721 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
8491 {
8492 8749721 int32_t t = o_tile;
8493 8749721 int32_t b = o_tile;
8494
8495 // Darknuts, but also Wizzrobes and Wallmasters
8496
3/4
✓ Branch 0 taken 3189553 times.
✓ Branch 1 taken 5241526 times.
✓ Branch 2 taken 318642 times.
✗ Branch 3 not taken.
8749721 switch(family)
8497 {
8498 case eeWALK:
8499
5/6
✓ Branch 0 taken 369324 times.
✓ Branch 1 taken 4872202 times.
✓ Branch 2 taken 261311 times.
✓ Branch 3 taken 108013 times.
✓ Branch 4 taken 261311 times.
✗ Branch 5 not taken.
5241526 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
8500 {
8501 261311 tile=s_tile;
8502 261311 t=s_tile;
8503 261311 b=s_tile;
8504 261311 }
8505
8506 5241526 break;
8507
8508 case eeTRAP:
8509
4/6
✓ Branch 0 taken 121158 times.
✓ Branch 1 taken 197484 times.
✓ Branch 2 taken 121158 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 121158 times.
318642 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
8510 {
8511 121158 tile=s_tile;
8512 121158 t=s_tile;
8513 121158 b=s_tile;
8514 121158 }
8515
8516 318642 break;
8517
8518 case eeSPINTILE:
8519 if(misc>=96 && do_animation)
8520 {
8521 tile=o_tile+frames*ndir;
8522 t=tile;
8523 }
8524
8525 break;
8526 }
8527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8749721 times.
8749721 if ( do_animation )
8528 {
8529
4/6
✓ Branch 0 taken 105723 times.
✓ Branch 1 taken 8643998 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77420 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8566578 times.
8749721 if(ndir!=0) switch(frames)
8530 {
8531 case 2:
8532 77420 tiledir_small(dir,ndir==4);
8533 77420 break;
8534
8535 case 3:
8536 tiledir_three(dir);
8537 break;
8538
8539 case 4:
8540 8566578 tiledir(dir,ndir==4);
8541 8566578 break;
8542 8643998 }
8543
8544
2/2
✓ Branch 0 taken 5241526 times.
✓ Branch 1 taken 3508195 times.
8749721 if(family==eeWALK)
8545
6/6
✓ Branch 0 taken 4175448 times.
✓ Branch 1 taken 1066078 times.
✓ Branch 2 taken 3924446 times.
✓ Branch 3 taken 1317080 times.
✓ Branch 4 taken 1042502 times.
✓ Branch 5 taken 274578 times.
5241526 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
8546 else
8547 3508195 tile+=f4;
8548 8749721 }
8549 8749721 return b;
8550 }
8551
8552 void enemy::tiledir_three(int32_t ndir)
8553 {
8554 if ( !do_animation ) return;
8555 flip=0;
8556
8557 switch(ndir)
8558 {
8559 case right:
8560 tile+=3;
8561 [[fallthrough]];
8562
8563 case left:
8564 tile+=3;
8565 [[fallthrough]];
8566
8567 case down:
8568 tile+=3;
8569 [[fallthrough]];
8570
8571 case up:
8572 break;
8573 }
8574 }
8575
8576 77420 void enemy::tiledir_small(int32_t ndir, bool fourdir)
8577 {
8578
1/2
✓ Branch 0 taken 77420 times.
✗ Branch 1 not taken.
77420 if ( !do_animation ) return;
8579 77420 flip=0;
8580
8581
4/9
✓ Branch 0 taken 17011 times.
✓ Branch 1 taken 16756 times.
✓ Branch 2 taken 22057 times.
✓ Branch 3 taken 21596 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
77420 switch(ndir)
8582 {
8583 case 8:
8584 case up:
8585 17011 break;
8586
8587 case 12:
8588 case down:
8589 16756 tile+=2;
8590 16756 break;
8591
8592 case 14:
8593 case left:
8594 22057 tile+=4;
8595 22057 break;
8596
8597 case 10:
8598 case right:
8599 21596 tile+=6;
8600 21596 break;
8601
8602 case 9:
8603 case r_up:
8604 if(fourdir)
8605 break;
8606
8607 tile+=10;
8608 break;
8609
8610 case 11:
8611 case r_down:
8612 if(fourdir)
8613 tile+=2;
8614 else
8615 tile+=14;
8616
8617 break;
8618
8619 case 13:
8620 case l_down:
8621 if(fourdir)
8622 tile+=2;
8623 else
8624 tile+=12;
8625
8626 break;
8627
8628 case 15:
8629 case l_up:
8630 if(fourdir)
8631 break;
8632
8633 tile+=8;
8634 break;
8635
8636 default:
8637 //dir=(zc_oldrand()*100)%8;
8638 //tiledir_small(dir);
8639 // flip=zc_oldrand()&3;
8640 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8641 break;
8642 }
8643 77420 }
8644
8645 10046684 void enemy::tiledir(int32_t ndir, bool fourdir)
8646 {
8647
1/2
✓ Branch 0 taken 10046684 times.
✗ Branch 1 not taken.
10046684 if ( !do_animation ) return;
8648 10046684 flip=0;
8649
8650
9/9
✓ Branch 0 taken 2011690 times.
✓ Branch 1 taken 1735796 times.
✓ Branch 2 taken 2400406 times.
✓ Branch 3 taken 2310034 times.
✓ Branch 4 taken 357701 times.
✓ Branch 5 taken 435144 times.
✓ Branch 6 taken 420302 times.
✓ Branch 7 taken 369004 times.
✓ Branch 8 taken 6607 times.
10046684 switch(ndir)
8651 {
8652 case 8:
8653 case up:
8654 2011690 break;
8655
8656 case 12:
8657 case down:
8658 1735796 tile+=4;
8659 1735796 break;
8660
8661 case 14:
8662 case left:
8663 2400406 tile+=8;
8664 2400406 break;
8665
8666 case 10:
8667 case right:
8668 2310034 tile+=12;
8669 2310034 break;
8670
8671 case 9:
8672 case r_up:
8673
2/2
✓ Branch 0 taken 53601 times.
✓ Branch 1 taken 304100 times.
357701 if(fourdir)
8674 53601 break;
8675 else
8676 304100 tile+=24;
8677
8678 304100 break;
8679
8680 case 11:
8681 case r_down:
8682
2/2
✓ Branch 0 taken 58633 times.
✓ Branch 1 taken 376511 times.
435144 if(fourdir)
8683 58633 tile+=4;
8684 else
8685 376511 tile+=32;
8686
8687 435144 break;
8688
8689 case 13:
8690 case l_down:
8691
2/2
✓ Branch 0 taken 61333 times.
✓ Branch 1 taken 358969 times.
420302 if(fourdir)
8692 61333 tile+=4;
8693 else
8694 358969 tile+=28;
8695
8696 420302 break;
8697
8698 case 15:
8699 case l_up:
8700
2/2
✓ Branch 0 taken 46455 times.
✓ Branch 1 taken 322549 times.
369004 if(fourdir)
8701 46455 break;
8702 else
8703 322549 tile+=20;
8704
8705 322549 break;
8706
8707 default:
8708 //dir=(zc_oldrand()*100)%8;
8709 //tiledir(dir);
8710 // flip=zc_oldrand()&3;
8711 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8712 6607 break;
8713 }
8714 10046684 }
8715
8716 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
8717 {
8718
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
8719 3868 flip=0;
8720
8721
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
8722 {
8723 case 8:
8724 case up:
8725 297 break;
8726
8727 case 12:
8728 case down:
8729 tile+=8;
8730 break;
8731
8732 case 14:
8733 case left:
8734 195 tile+=40;
8735 195 break;
8736
8737 case 10:
8738 case right:
8739 179 tile+=48;
8740 179 break;
8741
8742 case 9:
8743 case r_up:
8744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
8745 break;
8746
8747 306 tile+=88;
8748 306 break;
8749
8750 case 11:
8751 case r_down:
8752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
8753 tile+=8;
8754 else
8755 1235 tile+=128;
8756
8757 1235 break;
8758
8759 case 13:
8760 case l_down:
8761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
8762 tile+=8;
8763 else
8764 1324 tile+=120;
8765
8766 1324 break;
8767
8768 case 15:
8769 case l_up:
8770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
8771 break;
8772
8773 332 tile+=80;
8774 332 break;
8775
8776 default:
8777 //dir=(zc_oldrand()*100)%8;
8778 //tiledir_big(dir);
8779 // flip=zc_oldrand()&3;
8780 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
8781 break;
8782 }
8783 3868 }
8784
8785 17237734 void enemy::update_enemy_frame()
8786 {
8787
3/4
✓ Branch 0 taken 17237592 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17237592 times.
17237734 if(fallclk||drownclk) return;
8788
1/2
✓ Branch 0 taken 17237592 times.
✗ Branch 1 not taken.
17237592 if (!do_animation)
8789 return;
8790
8791
3/4
✓ Branch 0 taken 215596 times.
✓ Branch 1 taken 17021996 times.
✓ Branch 2 taken 215596 times.
✗ Branch 3 not taken.
17237592 if (get_bit(quest_rules,qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
8792
8793
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
17237592 if(get_bit(quest_rules,qr_ANONE_NOANIM)
8794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17237592 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17237592 && anim == aNONE && family != eeGUY)
8795 return;
8796
2/2
✓ Branch 0 taken 16960939 times.
✓ Branch 1 taken 276653 times.
17237592 int32_t newfrate = zc_max(frate,4);
8797 17237592 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
8798 17237592 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
8799
2/2
✓ Branch 0 taken 13040976 times.
✓ Branch 1 taken 4196616 times.
17237592 int32_t fx = get_bit(quest_rules, qr_NEWENEMYTILES) ? f4 : f2;
8800 17237592 tile = o_tile;
8801 17237592 int32_t basetile = o_tile;
8802 17237592 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
8803 17237592 bool ignore_extend = false;
8804
34/40
✓ Branch 0 taken 67625 times.
✓ Branch 1 taken 2553 times.
✓ Branch 2 taken 35552 times.
✓ Branch 3 taken 829242 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 46675 times.
✓ Branch 7 taken 202996 times.
✓ Branch 8 taken 125758 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2100562 times.
✓ Branch 12 taken 28657 times.
✓ Branch 13 taken 48420 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 199178 times.
✓ Branch 16 taken 595734 times.
✓ Branch 17 taken 105723 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 48711 times.
✓ Branch 20 taken 114069 times.
✓ Branch 21 taken 400124 times.
✓ Branch 22 taken 626088 times.
✓ Branch 23 taken 596152 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 77420 times.
✓ Branch 26 taken 1882394 times.
✓ Branch 27 taken 3306355 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 160855 times.
✓ Branch 30 taken 319741 times.
✓ Branch 31 taken 442753 times.
✓ Branch 32 taken 45658 times.
✓ Branch 33 taken 1192542 times.
✓ Branch 34 taken 21820 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3036014 times.
✓ Branch 37 taken 281252 times.
✓ Branch 38 taken 39993 times.
✓ Branch 39 taken 36233 times.
17237592 switch(anim)
8805 {
8806
8807 case aDONGO:
8808 {
8809 28657 int32_t fr = stunclk>0 ? 16 : 8;
8810
8811
6/6
✓ Branch 0 taken 27559 times.
✓ Branch 1 taken 1098 times.
✓ Branch 2 taken 3456 times.
✓ Branch 3 taken 24103 times.
✓ Branch 4 taken 1152 times.
✓ Branch 5 taken 2304 times.
28657 if(!dying && clk2>0 && clk2<=64)
8812 {
8813 // bloated
8814
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 512 times.
2304 switch(dir)
8815 {
8816 case up:
8817 512 tile+=9;
8818 512 flip=0;
8819 512 xofs=0;
8820 512 dummy_int[1]=0; //no additional tiles
8821 512 break;
8822
8823 case down:
8824 256 tile+=7;
8825 256 flip=0;
8826 256 xofs=0;
8827 256 dummy_int[1]=0; //no additional tiles
8828 256 break;
8829
8830 case left:
8831 1024 flip=1;
8832 1024 tile+=4;
8833 1024 xofs=16;
8834 1024 dummy_int[1]=1; //second tile is next tile
8835 1024 break;
8836
8837 case right:
8838 512 flip=0;
8839 512 tile+=5;
8840 512 xofs=16;
8841 512 dummy_int[1]=-1; //second tile is previous tile
8842 512 break;
8843 }
8844 2304 }
8845
4/4
✓ Branch 0 taken 1098 times.
✓ Branch 1 taken 25255 times.
✓ Branch 2 taken 568 times.
✓ Branch 3 taken 530 times.
26353 else if(!dying || clk2>19)
8846 {
8847 // normal
8848
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5442 times.
✓ Branch 2 taken 5800 times.
✓ Branch 3 taken 8935 times.
✓ Branch 4 taken 5646 times.
25823 switch(dir)
8849 {
8850 case up:
8851 5442 tile+=8;
8852 5442 flip=(clk&fr)?1:0;
8853 5442 xofs=0;
8854 5442 dummy_int[1]=0; //no additional tiles
8855 5442 break;
8856
8857 case down:
8858 5800 tile+=6;
8859 5800 flip=(clk&fr)?1:0;
8860 5800 xofs=0;
8861 5800 dummy_int[1]=0; //no additional tiles
8862 5800 break;
8863
8864 case left:
8865 8935 flip=1;
8866 8935 tile+=(clk&fr)?2:0;
8867 8935 xofs=16;
8868 8935 dummy_int[1]=1; //second tile is next tile
8869 8935 break;
8870
8871 case right:
8872 5646 flip=0;
8873 5646 tile+=(clk&fr)?3:1;
8874 5646 xofs=16;
8875 5646 dummy_int[1]=-1; //second tile is next tile
8876 5646 break;
8877 }
8878 25823 }
8879 }
8880 28657 break;
8881
8882 case aNEWDONGO:
8883 {
8884 48420 int32_t fr4=0;
8885
8886
6/6
✓ Branch 0 taken 46728 times.
✓ Branch 1 taken 1692 times.
✓ Branch 2 taken 3648 times.
✓ Branch 3 taken 43080 times.
✓ Branch 4 taken 1216 times.
✓ Branch 5 taken 2432 times.
48420 if(!dying && clk2>0 && clk2<=64)
8887 {
8888 // bloated
8889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2432 times.
2432 if(clk2>=0)
8890 {
8891 2432 fr4=3;
8892 2432 }
8893
8894
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 1862 times.
2432 if(clk2>=16)
8895 {
8896 1862 fr4=2;
8897 1862 }
8898
8899
2/2
✓ Branch 0 taken 1178 times.
✓ Branch 1 taken 1254 times.
2432 if(clk2>=32)
8900 {
8901 1254 fr4=1;
8902 1254 }
8903
8904
2/2
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 646 times.
2432 if(clk2>=48)
8905 {
8906 646 fr4=0;
8907 646 }
8908
8909
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1024 times.
2432 switch(dir)
8910 {
8911 case up:
8912 256 xofs=0;
8913 256 tile+=8+fr4;
8914 256 dummy_int[1]=0; //no additional tiles
8915 256 break;
8916
8917 case down:
8918 576 xofs=0;
8919 576 tile+=12+fr4;
8920 576 dummy_int[1]=0; //no additional tiles
8921 576 break;
8922
8923 case left:
8924 576 tile+=29+(2*fr4);
8925 576 xofs=16;
8926 576 dummy_int[1]=-1; //second tile is previous tile
8927 576 break;
8928
8929 case right:
8930 1024 tile+=49+(2*fr4);
8931 1024 xofs=16;
8932 1024 dummy_int[1]=-1; //second tile is previous tile
8933 1024 break;
8934 }
8935 2432 }
8936
4/4
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 44296 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 769 times.
45988 else if(!dying || clk2>19)
8937 {
8938 // normal
8939
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8569 times.
✓ Branch 2 taken 8925 times.
✓ Branch 3 taken 13235 times.
✓ Branch 4 taken 14490 times.
45219 switch(dir)
8940 {
8941 case up:
8942 8569 xofs=0;
8943 8569 tile+=((clk&12)>>2);
8944 8569 dummy_int[1]=0; //no additional tiles
8945 8569 break;
8946
8947 case down:
8948 8925 xofs=0;
8949 8925 tile+=4+((clk&12)>>2);
8950 8925 dummy_int[1]=0; //no additional tiles
8951 8925 break;
8952
8953 case left:
8954 13235 tile+=21+((clk&12)>>1);
8955 13235 xofs=16;
8956 13235 dummy_int[1]=-1; //second tile is previous tile
8957 13235 break;
8958
8959 case right:
8960 14490 flip=0;
8961 14490 tile+=41+((clk&12)>>1);
8962 14490 xofs=16;
8963 14490 dummy_int[1]=-1; //second tile is previous tile
8964 14490 break;
8965 }
8966 45219 }
8967 }
8968 48420 break;
8969
8970 case aDONGOBS:
8971 {
8972 818 int32_t fr4=0;
8973
8974
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
8975 {
8976 // bloated
8977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
8978 {
8979 128 fr4=3;
8980 128 }
8981
8982
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
8983 {
8984 98 fr4=2;
8985 98 }
8986
8987
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
8988 {
8989 66 fr4=1;
8990 66 }
8991
8992
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
8993 {
8994 34 fr4=0;
8995 34 }
8996
8997
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
8998 {
8999 case up:
9000 tile+=28+fr4;
9001 yofs+=8;
9002 dummy_int[1]=-20; //second tile change
9003 dummy_int[2]=0; //new xofs change
9004 dummy_int[3]=-16; //new xofs change
9005 break;
9006
9007 case down:
9008 tile+=12+fr4;
9009 yofs-=8;
9010 dummy_int[1]=20; //second tile change
9011 dummy_int[2]=0; //new xofs change
9012 dummy_int[3]=16; //new xofs change
9013 break;
9014
9015 case left:
9016 128 tile+=49+(2*fr4);
9017 128 xofs+=8;
9018 128 dummy_int[1]=-1; //second tile change
9019 128 dummy_int[2]=-16; //new xofs change
9020 128 dummy_int[3]=0; //new xofs change
9021 128 break;
9022
9023 case right:
9024 tile+=69+(2*fr4);
9025 xofs+=8;
9026 dummy_int[1]=-1; //second tile change
9027 dummy_int[2]=-16; //new xofs change
9028 dummy_int[3]=0; //new xofs change
9029 break;
9030 }
9031 128 }
9032
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
9033 {
9034 // normal
9035
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
9036 {
9037 case up:
9038 96 tile+=20+((clk&24)>>3);
9039 96 yofs+=8;
9040 96 dummy_int[1]=-20; //second tile change
9041 96 dummy_int[2]=0; //new xofs change
9042 96 dummy_int[3]=-16; //new xofs change
9043 96 break;
9044
9045 case down:
9046 129 tile+=4+((clk&24)>>3);
9047 129 yofs-=8;
9048 129 dummy_int[1]=20; //second tile change
9049 129 dummy_int[2]=0; //new xofs change
9050 129 dummy_int[3]=16; //new xofs change
9051 129 break;
9052
9053 case left:
9054 332 xofs=-8;
9055 332 tile+=40+((clk&24)>>2);
9056 332 dummy_int[1]=1; //second tile change
9057 332 dummy_int[2]=16; //new xofs change
9058 332 dummy_int[3]=0; //new xofs change
9059 332 break;
9060
9061 case right:
9062 97 tile+=60+((clk&24)>>2);
9063 97 xofs=-8;
9064 97 dummy_int[1]=1; //second tile change
9065 97 dummy_int[2]=16; //new xofs change
9066 97 dummy_int[3]=0; //new xofs change
9067 97 break;
9068 }
9069 654 }
9070 }
9071 818 break;
9072
9073 case aWIZZ:
9074 {
9075 // if(d->misc1)
9076
2/2
✓ Branch 0 taken 55336 times.
✓ Branch 1 taken 143842 times.
199178 if(dmisc1)
9077 {
9078
2/2
✓ Branch 0 taken 27886 times.
✓ Branch 1 taken 27450 times.
55336 if(clk&8)
9079 {
9080 27450 ++tile;
9081 27450 }
9082 55336 }
9083 else
9084 {
9085
2/2
✓ Branch 0 taken 71986 times.
✓ Branch 1 taken 71856 times.
143842 if(frame&4)
9086 {
9087 71856 ++tile;
9088 71856 }
9089 }
9090
9091
4/4
✓ Branch 0 taken 33876 times.
✓ Branch 1 taken 62571 times.
✓ Branch 2 taken 67454 times.
✓ Branch 3 taken 35277 times.
199178 switch(dir)
9092 {
9093 case 9:
9094 case 15:
9095 case up:
9096 33876 tile+=2;
9097 33876 break;
9098
9099 case down:
9100 35277 break;
9101
9102 case 13:
9103 case left:
9104 62571 flip=1;
9105 62571 break;
9106
9107 default:
9108 67454 flip=0;
9109 67454 break;
9110 }
9111 }
9112 199178 break;
9113
9114 case aNEWWIZZ:
9115 {
9116 595734 tiledir(dir,true);
9117
9118 // if(d->misc1) //walking wizzrobe
9119
2/2
✓ Branch 0 taken 316790 times.
✓ Branch 1 taken 278944 times.
595734 if(dmisc1) //walking wizzrobe
9120 {
9121
2/2
✓ Branch 0 taken 159200 times.
✓ Branch 1 taken 157590 times.
316790 if(clk&8)
9122 {
9123 157590 tile+=2;
9124 157590 }
9125
9126
2/2
✓ Branch 0 taken 158616 times.
✓ Branch 1 taken 158174 times.
316790 if(clk&4)
9127 {
9128 158174 tile+=1;
9129 158174 }
9130
9131
2/4
✓ Branch 0 taken 316790 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 316790 times.
316790 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
9132 {
9133
2/2
✓ Branch 0 taken 283104 times.
✓ Branch 1 taken 33686 times.
316790 if(dummy_int[1]>0)
9134 {
9135 33686 tile+=40;
9136 33686 }
9137 316790 }
9138 316790 }
9139 else
9140 {
9141
4/4
✓ Branch 0 taken 255725 times.
✓ Branch 1 taken 23219 times.
✓ Branch 2 taken 59829 times.
✓ Branch 3 taken 195896 times.
278944 if(dummy_bool[1]||dummy_bool[2])
9142 {
9143 83048 tile+=20;
9144
9145
2/2
✓ Branch 0 taken 23219 times.
✓ Branch 1 taken 59829 times.
83048 if(dummy_bool[2])
9146 {
9147 59829 tile+=20;
9148 59829 }
9149 83048 }
9150
9151 278944 tile+=((frame>>1)&3);
9152 }
9153 }
9154 595734 break;
9155
9156 case a3FRM:
9157 {
9158
2/2
✓ Branch 0 taken 25554 times.
✓ Branch 1 taken 80169 times.
105723 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
9159 }
9160 105723 break;
9161
9162 case a3FRM4DIR:
9163 {
9164 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
9165 }
9166 break;
9167
9168 case aVIRE:
9169 {
9170
2/2
✓ Branch 0 taken 37532 times.
✓ Branch 1 taken 11179 times.
48711 if(dir==up)
9171 {
9172 11179 tile+=2;
9173 11179 }
9174
9175 48711 tile+=fx;
9176 }
9177 48711 break;
9178
9179 case aROPE:
9180 {
9181 67625 tile+=(1-fx);
9182 67625 flip = dir==left ? 1:0;
9183 }
9184 67625 break;
9185
9186 case aZORA:
9187 {
9188 int32_t dl;
9189
9190
2/2
✓ Branch 0 taken 23518 times.
✓ Branch 1 taken 90551 times.
114069 if(clk<36)
9191 {
9192 23518 dl=clk+5;
9193 23518 goto waves2;
9194 }
9195
9196
2/2
✓ Branch 0 taken 42599 times.
✓ Branch 1 taken 47952 times.
90551 if(clk<36+66)
9197
2/2
✓ Branch 0 taken 23778 times.
✓ Branch 1 taken 18821 times.
42599 tile=(dir==up)?o_tile+1:o_tile;
9198 else
9199 {
9200 47952 dl=clk-36-66;
9201 waves2:
9202 71470 tile=((dl/11)&1)+s_tile;
9203 71470 basetile = s_tile;
9204 }
9205 }
9206 114069 break;
9207
9208 case aNEWZORA:
9209 {
9210 400124 f4=(clk/16)%4;
9211
9212 400124 tiledir(dir,true);
9213 int32_t dl;
9214
9215
4/4
✓ Branch 0 taken 288116 times.
✓ Branch 1 taken 112008 times.
✓ Branch 2 taken 151092 times.
✓ Branch 3 taken 137024 times.
400124 if((clk>35)&&(clk<36+67)) //surfaced
9216 {
9217
4/4
✓ Branch 0 taken 117068 times.
✓ Branch 1 taken 19956 times.
✓ Branch 2 taken 16724 times.
✓ Branch 3 taken 100344 times.
137024 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
9218 {
9219 100344 tile+=80;
9220 100344 } //mouth closed
9221 else
9222 {
9223 36680 tile+=40;
9224 }
9225
9226 137024 tile+=f4;
9227 137024 }
9228 else
9229 {
9230
2/2
✓ Branch 0 taken 112008 times.
✓ Branch 1 taken 151092 times.
263100 if(clk<36)
9231 {
9232 112008 dl=clk+5;
9233 112008 }
9234 else
9235 {
9236 151092 dl=clk-36-66;
9237 }
9238
9239 263100 tile+=((dl/5)&3);
9240 }
9241 }
9242 400124 break;
9243
9244 case a4FRM4EYE:
9245 case a2FRM4EYE:
9246 case a4FRM8EYE:
9247 case a4FRM8EYEB: //big version
9248 case a4FRM4EYEB:
9249 {
9250 125758 tilerows = 2;
9251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125758 times.
125758 int fakex = x + 8*(zc_max(1,txsz)-1);
9252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125758 times.
125758 int fakey = y + 8*(zc_max(1,tysz)-1);
9253 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9254 125758 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
9255 125758 int32_t lookat=zc_oldrand()&15;
9256
9257
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 84804 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
125758 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
9258 {
9259 20770 lookat=l_down;
9260 20770 }
9261
4/4
✓ Branch 0 taken 41154 times.
✓ Branch 1 taken 63834 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20970 times.
104988 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
9262 {
9263 20970 lookat=down;
9264 20970 }
9265
4/4
✓ Branch 0 taken 33302 times.
✓ Branch 1 taken 50716 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13118 times.
84018 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
9266 {
9267 13118 lookat=r_down;
9268 13118 }
9269
4/4
✓ Branch 0 taken 31638 times.
✓ Branch 1 taken 39262 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11454 times.
70900 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
9270 {
9271 11454 lookat=right;
9272 11454 }
9273
4/4
✓ Branch 0 taken 24538 times.
✓ Branch 1 taken 34908 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4354 times.
59446 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
9274 {
9275 4354 lookat=r_up;
9276 4354 }
9277
4/4
✓ Branch 0 taken 25602 times.
✓ Branch 1 taken 29490 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5418 times.
55092 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
9278 {
9279 5418 lookat=up;
9280 5418 }
9281
4/4
✓ Branch 0 taken 29766 times.
✓ Branch 1 taken 19908 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 9582 times.
49674 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
9282 {
9283 9582 lookat=l_up;
9284 9582 }
9285 else
9286 {
9287 40092 lookat=left;
9288 }
9289
9290 125758 int32_t dir2 = dir;
9291 125758 dir = lookat;
9292
3/6
✓ Branch 0 taken 125758 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125758 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 125758 times.
125758 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
9293 else
9294 {
9295 tiledir_big(dir,(anim == a4FRM4EYEB));
9296 tile+=2*f4;
9297 ignore_extend = true;
9298 }
9299 125758 dir = dir2;
9300 }
9301 125758 break;
9302
9303 case aFLIP:
9304 {
9305 626088 flip = f2&1;
9306 }
9307 626088 break;
9308
9309 case a2FRM:
9310 {
9311 596152 tile += (1-f2);
9312 }
9313 596152 break;
9314
9315 case a2FRMB:
9316 {
9317 tile+= 2*(1-f2);
9318 ignore_extend = true;
9319 }
9320 break;
9321
9322 case a2FRM4DIR:
9323 {
9324 77420 basetile = n_frame_n_dir(2, 4, f2&1);
9325 }
9326 77420 break;
9327
9328 case a4FRM4DIRF:
9329 {
9330 1882394 basetile = n_frame_n_dir(4,4,f4);
9331
9332
2/2
✓ Branch 0 taken 1190475 times.
✓ Branch 1 taken 691919 times.
1882394 if(clk2>0) //stopped to fire
9333 {
9334 691919 tile+=20;
9335
9336
2/2
✓ Branch 0 taken 332572 times.
✓ Branch 1 taken 359347 times.
691919 if(clk2<17) //firing
9337 {
9338 359347 tile+=20;
9339 359347 }
9340 691919 }
9341 }
9342 1882394 break;
9343
9344 case a4FRM4DIR:
9345 {
9346 3306355 basetile = n_frame_n_dir(4,4,f4);
9347 }
9348 3306355 break;
9349
9350 case a4FRM8DIRF:
9351 {
9352 tilerows = 2;
9353 basetile = n_frame_n_dir(4,8,f4);
9354
9355 if(clk2>0) //stopped to fire
9356 {
9357 tile+=40;
9358
9359 if(clk2<17) //firing
9360 {
9361 tile+=40;
9362 }
9363 }
9364 }
9365 break;
9366
9367 case a4FRM8DIRB:
9368 case a4FRM8DIRFB:
9369 {
9370 3868 tilerows = 2;
9371 3868 tiledir_big(dir,false);
9372 3868 tile+=2*f4;
9373
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
9374 {
9375 tile+=80;
9376
9377 if(clk2<17) //firing
9378 {
9379 tile+=80;
9380 }
9381 }
9382 3868 ignore_extend = true;
9383 }
9384 3868 break;
9385
9386 case a4FRM4DIRB:
9387 case a4FRM4DIRFB:
9388 {
9389 tilerows = 2;
9390 tiledir_big(dir,true);
9391 tile+=2*f4;
9392 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
9393 {
9394 tile+=40;
9395
9396 if(clk2<17) //firing
9397 {
9398 tile+=40;
9399 }
9400 }
9401 ignore_extend = true;
9402 }
9403 break;
9404
9405 case aOCTO:
9406 {
9407
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35999 times.
✓ Branch 2 taken 39336 times.
✓ Branch 3 taken 47224 times.
✓ Branch 4 taken 38296 times.
160855 switch(dir)
9408 {
9409 case up:
9410 35999 flip = 2;
9411 35999 break;
9412
9413 case down:
9414 39336 flip = 0;
9415 39336 break;
9416
9417 case left:
9418 47224 flip = 0;
9419 47224 tile += 2;
9420 47224 break;
9421
9422 case right:
9423 38296 flip = 1;
9424 38296 tile += 2;
9425 38296 break;
9426 }
9427
9428 160855 tile+=f2;
9429 }
9430 160855 break;
9431
9432 case aWALK:
9433 {
9434
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 61404 times.
✓ Branch 2 taken 71505 times.
✓ Branch 3 taken 92937 times.
✓ Branch 4 taken 93895 times.
319741 switch(dir)
9435 {
9436 case up:
9437 61404 tile+=3;
9438 61404 flip = f2;
9439 61404 break;
9440
9441 case down:
9442 71505 tile+=2;
9443 71505 flip = f2;
9444 71505 break;
9445
9446 case left:
9447 92937 flip=1;
9448 92937 tile += f2;
9449 92937 break;
9450
9451 case right:
9452 93895 flip=0;
9453 93895 tile += f2;
9454 93895 break;
9455 }
9456 }
9457 319741 break;
9458
9459 case aDWALK:
9460 {
9461
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 442753 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
442753 if((get_bit(quest_rules,qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
9462 {
9463 tile=s_tile;
9464 basetile = s_tile;
9465 }
9466
9467
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 91056 times.
✓ Branch 2 taken 91679 times.
✓ Branch 3 taken 128932 times.
✓ Branch 4 taken 131086 times.
442753 switch(dir)
9468 {
9469 case up:
9470 91056 tile+=2;
9471 91056 flip=f2;
9472 91056 break;
9473
9474 case down:
9475 91679 flip=0;
9476 91679 tile+=(1-f2);
9477 91679 break;
9478
9479 case left:
9480 128932 flip=1;
9481 128932 tile+=(3+f2);
9482 128932 break;
9483
9484 case right:
9485 131086 flip=0;
9486 131086 tile+=(3+f2);
9487 131086 break;
9488 }
9489 }
9490 442753 break;
9491
9492 case aTEK:
9493 {
9494
2/2
✓ Branch 0 taken 26984 times.
✓ Branch 1 taken 18674 times.
45658 if(misc==0)
9495 {
9496 18674 tile += f2;
9497 18674 }
9498
2/2
✓ Branch 0 taken 14663 times.
✓ Branch 1 taken 12321 times.
26984 else if(misc!=1)
9499 {
9500 12321 ++tile;
9501 12321 }
9502 }
9503 45658 break;
9504
9505 case aNEWTEK:
9506 {
9507
2/2
✓ Branch 0 taken 300104 times.
✓ Branch 1 taken 892438 times.
1192542 if(step<0) //up
9508 {
9509
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147182 times.
✓ Branch 2 taken 152922 times.
300104 switch(clk3)
9510 {
9511 case left:
9512 147182 flip=0;
9513 147182 tile+=20;
9514 147182 break;
9515
9516 case right:
9517 152922 flip=0;
9518 152922 tile+=24;
9519 152922 break;
9520 }
9521 300104 }
9522
2/2
✓ Branch 0 taken 38135 times.
✓ Branch 1 taken 854303 times.
892438 else if(step==0)
9523 {
9524
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 28780 times.
✓ Branch 2 taken 9355 times.
38135 switch(clk3)
9525 {
9526 case left:
9527 28780 flip=0;
9528 28780 tile+=8;
9529 28780 break;
9530
9531 case right:
9532 9355 flip=0;
9533 9355 tile+=12;
9534 9355 break;
9535 }
9536 38135 } //down
9537 else
9538 {
9539
3/3
✓ Branch 0 taken 55883 times.
✓ Branch 1 taken 403679 times.
✓ Branch 2 taken 394741 times.
854303 switch(clk3)
9540 {
9541 case left:
9542 403679 flip=0;
9543 403679 tile+=28;
9544 403679 break;
9545
9546 case right:
9547 394741 flip=0;
9548 394741 tile+=32;
9549 394741 break;
9550 }
9551 }
9552
9553
2/2
✓ Branch 0 taken 757764 times.
✓ Branch 1 taken 434778 times.
1192542 if(misc==0)
9554 {
9555 434778 tile+=f4;
9556 434778 }
9557
2/2
✓ Branch 0 taken 367826 times.
✓ Branch 1 taken 389938 times.
757764 else if(misc!=1)
9558 {
9559 389938 tile+=2;
9560 389938 }
9561 }
9562 1192542 break;
9563
9564 case aARMOS:
9565 {
9566
2/2
✓ Branch 0 taken 732 times.
✓ Branch 1 taken 1821 times.
2553 if(!fading)
9567 {
9568 1821 tile += fx;
9569
9570
2/2
✓ Branch 0 taken 1151 times.
✓ Branch 1 taken 670 times.
1821 if(dir==up)
9571 670 tile += 2;
9572 1821 }
9573 }
9574 2553 break;
9575
9576 case aARMOS4:
9577 {
9578
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5907 times.
✓ Branch 2 taken 12136 times.
✓ Branch 3 taken 8764 times.
✓ Branch 4 taken 8745 times.
35552 switch(dir)
9579 {
9580 case up:
9581 5907 flip=0;
9582 5907 break;
9583
9584 case down:
9585 12136 flip=0;
9586 12136 tile+=4;
9587 12136 break;
9588
9589 case left:
9590 8764 flip=0;
9591 8764 tile+=8;
9592 8764 break;
9593
9594 case right:
9595 8745 flip=0;
9596 8745 tile+=12;
9597 8745 break;
9598 }
9599
9600
2/2
✓ Branch 0 taken 6441 times.
✓ Branch 1 taken 29111 times.
35552 if(!fading)
9601 {
9602 29111 tile+=f4;
9603 29111 }
9604 }
9605 35552 break;
9606
9607 case aGHINI:
9608 {
9609
3/4
✓ Branch 0 taken 4515 times.
✓ Branch 1 taken 5782 times.
✓ Branch 2 taken 11523 times.
✗ Branch 3 not taken.
21820 switch(dir)
9610 {
9611 case 8:
9612 case 9:
9613 case up:
9614 4515 ++tile;
9615 4515 flip=0;
9616 4515 break;
9617
9618 case 15:
9619 ++tile;
9620 flip=1;
9621 break;
9622
9623 case 10:
9624 case 11:
9625 case right:
9626 5782 flip=1;
9627 5782 break;
9628
9629 default:
9630 11523 flip=0;
9631 11523 break;
9632 }
9633 }
9634 21820 break;
9635
9636 case a2FRMPOS:
9637 {
9638 829242 tile+=posframe;
9639 }
9640 829242 break;
9641
9642 case a4FRMPOS4DIR:
9643 {
9644 216057 basetile = n_frame_n_dir(4,4,0);
9645 // tile+=f2;
9646 216057 tile+=posframe;
9647 }
9648 216057 break;
9649
9650 case a4FRMPOS4DIRF:
9651 {
9652 basetile = n_frame_n_dir(4,4,0);
9653
9654 if(clk2>0) //stopped to fire
9655 {
9656 tile+=20;
9657
9658 if(clk2<17) //firing
9659 {
9660 tile+=20;
9661 }
9662 }
9663
9664 // tile+=f2;
9665 tile+=posframe;
9666 }
9667 break;
9668
9669 case a4FRMPOS8DIR:
9670 {
9671 3036014 tilerows = 2;
9672 3036014 int32_t n = tile;
9673 3036014 basetile = n_frame_n_dir(4,8,0);
9674 // tile+=f2;
9675 3036014 tile+=posframe;
9676 }
9677 3036014 break;
9678
9679 case a4FRMPOS8DIRF:
9680 {
9681 tilerows = 2;
9682 basetile = n_frame_n_dir(4,8,0);
9683
9684 if(clk2>0) //stopped to fire
9685 {
9686 tile+=40;
9687
9688 if(clk2<17) //firing
9689 {
9690 tile+=40;
9691 }
9692 }
9693
9694 tile+=posframe;
9695 }
9696 break;
9697
9698 case aNEWLEV:
9699 {
9700 281252 tiledir(dir,true);
9701
9702
4/5
✓ Branch 0 taken 92728 times.
✓ Branch 1 taken 45439 times.
✓ Branch 2 taken 18283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124802 times.
281252 switch(misc)
9703 {
9704 case -1:
9705 case 0:
9706 92728 return;
9707
9708 case 1:
9709
9710 // case 5: cs = d->misc2; break;
9711 case 5:
9712 45439 cs = dmisc2;
9713 45439 break;
9714
9715 case 2:
9716 case 4:
9717 18283 tile += 20;
9718 18283 break;
9719
9720 case 3:
9721 124802 tile += 40;
9722 124802 break;
9723 }
9724
9725 188524 tile+=f4;
9726 }
9727 188524 break;
9728
9729 case aLEV:
9730 {
9731 39993 f4 = ((clk/5)&1);
9732
9733
4/5
✓ Branch 0 taken 19248 times.
✓ Branch 1 taken 4577 times.
✓ Branch 2 taken 2268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13900 times.
39993 switch(misc)
9734 {
9735 case -1:
9736 case 0:
9737 19248 return;
9738
9739 case 1:
9740
9741 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
9742 case 5:
9743 4577 tile += (f2) ? 1 : 0;
9744 4577 cs = dmisc2;
9745 4577 break;
9746
9747 case 2:
9748 case 4:
9749 2268 tile += 2;
9750 2268 break;
9751
9752 case 3:
9753 13900 tile += (f4) ? 4 : 3;
9754 13900 break;
9755 }
9756 }
9757 20745 break;
9758
9759 case aWALLM:
9760 {
9761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46675 times.
46675 if(!dummy_bool[1])
9762 {
9763 46675 tile += f2;
9764 46675 }
9765 }
9766 46675 break;
9767
9768 case aNEWWALLM:
9769 {
9770 202996 int32_t tempdir=0;
9771
9772
4/4
✓ Branch 0 taken 26549 times.
✓ Branch 1 taken 19916 times.
✓ Branch 2 taken 5582 times.
✓ Branch 3 taken 150949 times.
202996 switch(misc)
9773 {
9774 case 1:
9775 case 2:
9776 19916 tempdir=clk3;
9777 19916 break;
9778
9779 case 3:
9780 case 4:
9781 case 5:
9782 26549 tempdir=dir;
9783 26549 break;
9784
9785 case 6:
9786 case 7:
9787 5582 tempdir=clk3^1;
9788 5582 break;
9789 }
9790
9791 202996 tiledir(tempdir,true);
9792
9793
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 202418 times.
202996 if(!dummy_bool[1])
9794 {
9795 202418 tile+=f4;
9796 202418 }
9797 }
9798 202996 break;
9799
9800 case a4FRMNODIR:
9801 {
9802 36233 tile+=f4;
9803 }
9804 36233 break;
9805
9806 } // switch(d->anim)
9807
9808 // flashing
9809 // if(d->flags2 & guy_flashing)
9810
2/2
✓ Branch 0 taken 16769572 times.
✓ Branch 1 taken 356044 times.
17125616 if(flags2 & guy_flashing)
9811 {
9812 356044 cs = (frame&3) + 6;
9813 356044 }
9814
9815
2/2
✓ Branch 0 taken 17093502 times.
✓ Branch 1 taken 32114 times.
17125616 if(flags2&guy_transparent)
9816 {
9817 32114 drawstyle=1;
9818 32114 }
9819
9820 17125616 int32_t change = tile-basetile;
9821
9822
3/6
✓ Branch 0 taken 374939 times.
✓ Branch 1 taken 16750677 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 374939 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17125616 if(extend > 2 && (!ignore_extend || get_bit(quest_rules, qr_BROKEN_BIG_ENEMY_ANIMATION)))
9823 {
9824
2/2
✓ Branch 0 taken 374526 times.
✓ Branch 1 taken 413 times.
374939 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
9825 {
9826 374526 tile=basetile+txsz*change;
9827 374526 }
9828 else
9829 {
9830 413 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
9831 }
9832 374939 }
9833 else
9834 {
9835 16750677 tile=basetile+change;
9836 }
9837 17237734 }
9838
9839 45821 int32_t wpnsfx(int32_t wpn)
9840 {
9841
5/6
✓ Branch 0 taken 17448 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 16175 times.
✓ Branch 3 taken 8163 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3804 times.
45821 switch(wpn)
9842 {
9843 case ewFireTrail:
9844 case ewFlame:
9845 case ewFlame2Trail:
9846 case ewFlame2:
9847 17448 return WAV_FIRE;
9848
9849 case ewWind:
9850 case ewMagic:
9851 231 return WAV_WAND;
9852
9853 case ewIce:
9854 return WAV_ZN1ICE;
9855
9856 case ewRock:
9857
2/2
✓ Branch 0 taken 3540 times.
✓ Branch 1 taken 264 times.
3804 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1ROCK;
9858 3540 break;
9859
9860 case ewFireball2:
9861 case ewFireball:
9862
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16168 times.
16175 if(get_bit(quest_rules,qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
9863 16168 }
9864
9865 27871 return -1;
9866 45821 }
9867
9868 31833134 int32_t enemy::run_script(int32_t mode)
9869 {
9870
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 31833134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
31833134 if(switch_hooked && !get_bit(quest_rules, qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
9871
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 31833134 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
31833134 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
9872 31833134 return RUNSCRIPT_OK;
9873 int32_t ret = RUNSCRIPT_OK;
9874 alloc_scriptmem();
9875 switch(mode)
9876 {
9877 case MODE_NORMAL:
9878 return ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9879 case MODE_WAITDRAW:
9880 if(waitdraw)
9881 {
9882 ret = ZScriptVersion::RunScript(SCRIPT_NPC, script, getUID());
9883 waitdraw = 0;
9884 }
9885 break;
9886 }
9887 return ret;
9888 31833134 }
9889 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
9890 {
9891 return al_map_rgba(255,0,0,opacity);
9892 }
9893 /********************************/
9894 /********* Guy Class **********/
9895 /********************************/
9896
9897 // good guys, fires, fairy, and other non-enemies
9898 // based on enemy class b/c guys in dungeons act sort of like enemies
9899 // also easier to manage all the guys this way
9900 1950 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
9901 1950 {
9902 975 mainguy=mg;
9903 975 canfreeze=false;
9904 975 dir=down;
9905
3/6
✓ Branch 0 taken 975 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 975 times.
✓ Branch 4 taken 975 times.
✗ Branch 5 not taken.
975 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9906 975 hxofs=2;
9907 975 hzsz=8;
9908 975 hxsz=12;
9909 975 hysz=17;
9910
9911
10/12
✓ Branch 0 taken 975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 669 times.
✓ Branch 6 taken 297 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 114 times.
✓ Branch 9 taken 183 times.
✓ Branch 10 taken 11 times.
✓ Branch 11 taken 103 times.
975 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
9912 {
9913 872 superman = 1;
9914 872 hxofs=1000;
9915 872 }
9916 975 }
9917
9918 306271 bool guy::animate(int32_t index)
9919 {
9920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306271 times.
306271 if(switch_hooked) return enemy::animate(index);
9921
6/6
✓ Branch 0 taken 124996 times.
✓ Branch 1 taken 181275 times.
✓ Branch 2 taken 865 times.
✓ Branch 3 taken 124131 times.
✓ Branch 4 taken 424 times.
✓ Branch 5 taken 441 times.
306271 if(mainguy && clk==0 && misc==0)
9922 {
9923 441 setupscreen();
9924 441 misc = 1;
9925 441 }
9926
9927
4/4
✓ Branch 0 taken 124996 times.
✓ Branch 1 taken 181275 times.
✓ Branch 2 taken 124848 times.
✓ Branch 3 taken 148 times.
306271 if(mainguy && fadeclk==0)
9928 148 return true;
9929
9930 306123 hp=256; // good guys never die...
9931
9932
4/4
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 306039 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 3 times.
306123 if(hclk && !clk2)
9933 {
9934 // but if they get hit...
9935 3 ++clk2; // only do this once
9936
9937
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(!get_bit(quest_rules,qr_NOGUYFIRES))
9938 {
9939 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
9940 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
9941 1 }
9942 3 }
9943
9944 306123 return enemy::animate(index);
9945 306271 }
9946
9947 308291 void guy::draw(BITMAP *dest)
9948 {
9949 308291 update_enemy_frame();
9950
9951
6/6
✓ Branch 0 taken 126884 times.
✓ Branch 1 taken 181407 times.
✓ Branch 2 taken 10019 times.
✓ Branch 3 taken 116865 times.
✓ Branch 4 taken 5008 times.
✓ Branch 5 taken 5011 times.
308291 if(!mainguy || fadeclk<0 || fadeclk&1)
9952 303280 enemy::draw(dest);
9953 308291 }
9954
9955 /*******************************/
9956 /********* Enemies *********/
9957 /*******************************/
9958
9959 150 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9960 150 {
9961 75 clk4=0;
9962 75 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
9963 // Spawn type
9964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if(flags & guy_fadeflicker)
9965 {
9966 clk=0;
9967 superman = 1;
9968 fading=fade_flicker;
9969 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9970 dir=down;
9971
9972 if(!canmove(down,(zfix)8,spw_none,false))
9973 clk3=int32_t(13.0/step);
9974 }
9975
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 else if(flags & guy_fadeinstant)
9976 {
9977 clk=0;
9978 }
9979 75 SIZEflags = d->SIZEflags;
9980
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9981 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9982 // al_trace("Enemy txsz:%i\n", txsz);
9983
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9984
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
9985
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
9986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9987
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9988
1/2
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
75 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9989 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
75 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9992 {
9993 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9994 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9995 }
9996
9997
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 75 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
75 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
9998 75 }
9999
10000 39658 bool eFire::animate(int32_t index)
10001 {
10002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39658 times.
39658 if(switch_hooked) return enemy::animate(index);
10003
2/4
✓ Branch 0 taken 39658 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 39658 times.
39658 if(fallclk||drownclk) return enemy::animate(index);
10004
2/2
✓ Branch 0 taken 39430 times.
✓ Branch 1 taken 228 times.
39658 if(fading)
10005 {
10006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
228 if(++clk4 > 60)
10007 {
10008 clk4=0;
10009 superman=0;
10010 fading=0;
10011
10012 if(flags2&cmbflag_armos && z==0 && fakez==0)
10013 removearmos(x,y,ffcactivated);
10014
10015 clk2=0;
10016
10017 if(!canmove(down,(zfix)8,spw_none,false))
10018 {
10019 dir=0;
10020 y = y.getInt() & 0xF0;
10021 }
10022
10023 return Dead(index);
10024 }
10025
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
228 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10026 removearmos(x,y,ffcactivated);
10027 228 }
10028
10029 39658 return enemy::animate(index);
10030 39658 }
10031
10032 82490 void eFire::draw(BITMAP *dest)
10033 {
10034 82490 update_enemy_frame();
10035 82490 enemy::draw(dest);
10036 82490 }
10037
10038 97 int32_t eFire::takehit(weapon *w, weapon* realweap)
10039 {
10040 97 int32_t wpnId = w->id;
10041 97 int32_t wpnDir = w->dir;
10042
10043
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10044 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10045 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10046 {
10047 shield = false;
10048 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10049
10050 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10051 o_tile=s_tile;
10052 }
10053
10054 97 int32_t ret = enemy::takehit(w,realweap);
10055 97 return ret;
10056 }
10057
10058 void eFire::break_shield()
10059 {
10060 if(!shield)
10061 return;
10062
10063 flags&=~(inv_front | inv_back | inv_left | inv_right);
10064 shield=false;
10065
10066 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10067 o_tile=s_tile;
10068 }
10069
10070 2556 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10071 2556 {
10072 //zprint2("npct other::other\n");
10073 1278 clk4=0;
10074 1278 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10075
10076 // Spawn type
10077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
1278 if(flags & guy_fadeflicker)
10078 {
10079 clk=0;
10080 superman = 1;
10081 fading=fade_flicker;
10082 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10083 dir=down;
10084
10085 if(!canmove(down,(zfix)8,spw_none,false))
10086 clk3=int32_t(13.0/step);
10087 }
10088
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 else if(flags & guy_fadeinstant)
10089 {
10090 clk=0;
10091 }
10092 1278 SIZEflags = d->SIZEflags;
10093
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10094 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10095 // al_trace("Enemy txsz:%i\n", txsz);
10096
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10097
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10098
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10099
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10100
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10101
1/2
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10102 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10105 {
10106 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10107 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10108 }
10109
10110
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1278 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10111 1278 }
10112
10113 380627 bool eOther::animate(int32_t index)
10114 {
10115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 380627 times.
380627 if(switch_hooked) return enemy::animate(index);
10116
2/4
✓ Branch 0 taken 380627 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 380627 times.
380627 if(fallclk||drownclk) return enemy::animate(index);
10117 //zprint2("npct other::animate\n");
10118
1/2
✓ Branch 0 taken 380627 times.
✗ Branch 1 not taken.
380627 if(fading)
10119 {
10120 if(++clk4 > 60)
10121 {
10122 clk4=0;
10123 superman=0;
10124 fading=0;
10125
10126 if(flags2&cmbflag_armos && z==0 && fakez==0)
10127 removearmos(x,y,ffcactivated);
10128
10129 clk2=0;
10130
10131 if(!canmove(down,(zfix)8,spw_none,false))
10132 {
10133 dir=0;
10134 y = y.getInt() & 0xF0;
10135 }
10136
10137 return Dead(index);
10138 }
10139 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10140 removearmos(x,y,ffcactivated);
10141 }
10142
10143 380627 return enemy::animate(index);
10144 380627 }
10145
10146 398420 void eOther::draw(BITMAP *dest)
10147 {
10148 398420 update_enemy_frame();
10149 398420 enemy::draw(dest);
10150 398420 }
10151
10152 2767 int32_t eOther::takehit(weapon *w, weapon* realweap)
10153 {
10154 2767 int32_t wpnId = w->id;
10155 2767 int32_t wpnDir = w->dir;
10156
10157
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2750 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
2767 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10158 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10159 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10160 {
10161 shield = false;
10162 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10163
10164 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10165 o_tile=s_tile;
10166 }
10167
10168 2767 int32_t ret = enemy::takehit(w,realweap);
10169 2767 return ret;
10170 }
10171
10172 void eOther::break_shield()
10173 {
10174 if(!shield)
10175 return;
10176
10177 flags&=~(inv_front | inv_back | inv_left | inv_right);
10178 shield=false;
10179
10180 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10181 o_tile=s_tile;
10182 }
10183
10184
10185 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10186 {
10187 clk4=0;
10188 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10189
10190 // Spawn type
10191 if(flags & guy_fadeflicker)
10192 {
10193 clk=0;
10194 superman = 1;
10195 fading=fade_flicker;
10196 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10197 dir=down;
10198
10199 if(!canmove(down,(zfix)8,spw_none,false))
10200 clk3=int32_t(13.0/step);
10201 }
10202 else if(flags & guy_fadeinstant)
10203 {
10204 clk=0;
10205 }
10206 SIZEflags = d->SIZEflags;
10207 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10208 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10209 // al_trace("Enemy txsz:%i\n", txsz);
10210 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10211 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10212 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10213 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10214 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10215 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10216 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10217 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10218 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10219 {
10220 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10221 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10222 }
10223
10224 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10225 }
10226
10227 bool eScript::animate(int32_t index)
10228 {
10229 if(switch_hooked) return enemy::animate(index);
10230 if(fallclk||drownclk) return enemy::animate(index);
10231 if(fading)
10232 {
10233 if(++clk4 > 60)
10234 {
10235 clk4=0;
10236 superman=0;
10237 fading=0;
10238
10239 if(flags2&cmbflag_armos && z==0 && fakez==0)
10240 removearmos(x,y,ffcactivated);
10241
10242 clk2=0;
10243
10244 if(!canmove(down,(zfix)8,spw_none,false))
10245 {
10246 dir=0;
10247 y = y.getInt() & 0xF0;
10248 }
10249
10250 return Dead(index);
10251 }
10252 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10253 removearmos(x,y,ffcactivated);
10254 }
10255
10256 return enemy::animate(index);
10257 }
10258
10259 void eScript::draw(BITMAP *dest)
10260 {
10261 update_enemy_frame();
10262 enemy::draw(dest);
10263 }
10264
10265 int32_t eScript::takehit(weapon *w, weapon* realweap)
10266 {
10267 int32_t wpnId = w->id;
10268 int32_t wpnDir = w->dir;
10269
10270 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10271 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10272 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10273 {
10274 shield = false;
10275 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10276
10277 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10278 o_tile=s_tile;
10279 }
10280
10281 int32_t ret = enemy::takehit(w,realweap);
10282 return ret;
10283 }
10284
10285 void eScript::break_shield()
10286 {
10287 if(!shield)
10288 return;
10289
10290 flags&=~(inv_front | inv_back | inv_left | inv_right);
10291 shield=false;
10292
10293 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10294 o_tile=s_tile;
10295 }
10296
10297
10298 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10299 {
10300 clk4=0;
10301 hyofs = -32768; //No hitbox initially.
10302 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10303
10304 // Spawn type
10305 if(flags & guy_fadeflicker)
10306 {
10307 clk=0;
10308 superman = 1;
10309 fading=fade_flicker;
10310 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10311 dir=down;
10312
10313 if(!canmove(down,(zfix)8,spw_none,false))
10314 clk3=int32_t(13.0/step);
10315 }
10316 else if(flags & guy_fadeinstant)
10317 {
10318 clk=0;
10319 }
10320 SIZEflags = d->SIZEflags;
10321 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10322 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10323 // al_trace("Enemy txsz:%i\n", txsz);
10324 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10325 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10326 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10327 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10328 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10329 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10330 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10331 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10332 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10333 {
10334 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10335 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10336 }
10337
10338 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10339 }
10340
10341 bool eFriendly::animate(int32_t index)
10342 {
10343 if(switch_hooked) return enemy::animate(index);
10344 if(fallclk||drownclk) return enemy::animate(index);
10345 if(fading)
10346 {
10347 if(++clk4 > 60)
10348 {
10349 clk4=0;
10350 superman=0;
10351 fading=0;
10352
10353 if(flags2&cmbflag_armos && z==0 && fakez==0)
10354 removearmos(x,y,ffcactivated);
10355
10356 clk2=0;
10357
10358 if(!canmove(down,(zfix)8,spw_none,false))
10359 {
10360 dir=0;
10361 y = y.getInt() & 0xF0;
10362 }
10363
10364 return Dead(index);
10365 }
10366 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
10367 removearmos(x,y,ffcactivated);
10368 }
10369
10370 return enemy::animate(index);
10371 }
10372
10373 void eFriendly::draw(BITMAP *dest)
10374 {
10375 update_enemy_frame();
10376 enemy::draw(dest);
10377 }
10378
10379 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
10380 {
10381 int32_t wpnId = w->id;
10382 int32_t wpnDir = w->dir;
10383
10384 if(wpnId==wHammer && shield && (flags & guy_bkshield)
10385 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
10386 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
10387 {
10388 shield = false;
10389 flags &= ~(inv_left|inv_right|inv_back|inv_front);
10390
10391 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10392 o_tile=s_tile;
10393 }
10394
10395 int32_t ret = enemy::takehit(w,realweap);
10396 return ret;
10397 }
10398
10399 void eFriendly::break_shield()
10400 {
10401 if(!shield)
10402 return;
10403
10404 flags&=~(inv_front | inv_back | inv_left | inv_right);
10405 shield=false;
10406
10407 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
10408 o_tile=s_tile;
10409 }
10410
10411
10412 283483 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
10413 {
10414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 283483 times.
283483 if (ffcactive)
10415 {
10416 removearmosffc(ffcactive-1);
10417 return;
10418 }
10419
2/2
✓ Branch 0 taken 282929 times.
✓ Branch 1 taken 554 times.
283483 if(did_armos)
10420 {
10421 282929 return;
10422 }
10423
10424 554 did_armos=true;
10425 554 ax&=0xF0;
10426 554 ay&=0xF0;
10427 554 int32_t cd = (ax>>4)+ay;
10428 554 int32_t f = MAPFLAG(ax,ay);
10429 554 int32_t f2 = MAPCOMBOFLAG(ax,ay);
10430
10431
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 92 times.
554 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
10432 {
10433 462 return;
10434 }
10435
10436 92 tmpscr->data[cd] = tmpscr->undercombo;
10437 92 tmpscr->cset[cd] = tmpscr->undercset;
10438 92 tmpscr->sflag[cd] = 0;
10439
10440
3/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
92 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
10441 {
10442 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
10443 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
10444 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
10445 20 sfx(tmpscr->secretsfx);
10446 20 }
10447
10448
3/4
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
92 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
10449 {
10450
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10451 {
10452 1 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10453 1 sfx(tmpscr->secretsfx);
10454 1 }
10455 1 }
10456
10457 92 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
10458 283483 }
10459
10460 void enemy::removearmosffc(int32_t pos)
10461 {
10462 if(did_armos)
10463 {
10464 return;
10465 }
10466
10467 did_armos=true;
10468 ffcdata& ffc = tmpscr->ffcs[pos];
10469 newcombo const& cmb = combobuf[ffc.getData()];
10470 int32_t f2 = cmb.flag;
10471
10472 if(cmb.type!=cARMOS)
10473 {
10474 return;
10475 }
10476
10477 ffc.setData(tmpscr->undercombo);
10478 ffc.cset = tmpscr->undercset;
10479
10480 if(f2 == mfARMOS_SECRET)
10481 {
10482 ffc.setData(tmpscr->secretcombo[sSTAIRS]);
10483 ffc.cset = tmpscr->secretcset[sSTAIRS];
10484 sfx(tmpscr->secretsfx);
10485 }
10486
10487 if(f2 == mfARMOS_ITEM)
10488 {
10489 if(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
10490 {
10491 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
10492 sfx(tmpscr->secretsfx);
10493 }
10494 }
10495
10496 putcombo(scrollbuf,ffc.x,ffc.y,ffc.getData(),ffc.cset);
10497 }
10498
10499
10500 258 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10501 258 {
10502 129 fading=fade_flicker;
10503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10504 129 dir=12;
10505 129 movestatus=1;
10506
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 step=0;
10507 129 clk=0;
10508 129 clk4=0;
10509 129 SIZEflags = d->SIZEflags;
10510
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10511 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10512 // al_trace("Enemy txsz:%i\n", txsz);
10513
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10514
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10515
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10516
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10517
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10518
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10519 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10522 {
10523 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10524 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10525 }
10526
10527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10528 129 }
10529
10530 48119 bool eGhini::animate(int32_t index)
10531 {
10532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48119 times.
48119 if(switch_hooked) return enemy::animate(index);
10533
2/4
✓ Branch 0 taken 48119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 48119 times.
48119 if(fallclk||drownclk) return enemy::animate(index);
10534
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 48083 times.
48119 if(dying)
10535 36 return Dead(index);
10536
10537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48083 times.
48083 if(dmisc1)
10538 {
10539
2/2
✓ Branch 0 taken 40347 times.
✓ Branch 1 taken 7736 times.
48083 if(misc)
10540 {
10541
2/2
✓ Branch 0 taken 10797 times.
✓ Branch 1 taken 29550 times.
40347 if(clk4>160)
10542 29550 misc=2;
10543
10544
2/2
✓ Branch 0 taken 10797 times.
✓ Branch 1 taken 29550 times.
40347 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
10545 40347 removearmos(x,y,ffcactivated);
10546 40347 }
10547
2/2
✓ Branch 0 taken 7612 times.
✓ Branch 1 taken 124 times.
7736 else if(clk4>=60)
10548 {
10549 124 misc=1;
10550 124 clk3=32;
10551 124 fading=0;
10552
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if (ffcactivated > 0)
10553 {
10554 guygridffc[ffcactivated-1] = 0;
10555 removearmosffc(ffcactivated-1);
10556 }
10557 else
10558 {
10559 124 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
10560 124 removearmos(x,y);
10561 }
10562 124 }
10563 48083 }
10564
10565 48083 clk4++;
10566
10567 48083 return enemy::animate(index);
10568 48119 }
10569
10570 96296 void eGhini::draw(BITMAP *dest)
10571 {
10572 96296 update_enemy_frame();
10573 96296 enemy::draw(dest);
10574 96296 }
10575
10576 2 void eGhini::kickbucket()
10577 {
10578 2 hp=-1000; // don't call death_sfx()
10579 2 }
10580
10581
3/6
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2000 times.
✗ Branch 5 not taken.
6000 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10582 4000 {
10583
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 old_y=y;
10584 2000 dir=down;
10585 2000 misc=1;
10586 2000 clk=-15;
10587
10588
2/2
✓ Branch 0 taken 1980 times.
✓ Branch 1 taken 20 times.
2000 if(!BSZ)
10589
1/2
✓ Branch 0 taken 1980 times.
✗ Branch 1 not taken.
1980 clk*=zc_oldrand()%3+1;
10590
10591 // avoid divide by 0 errors
10592
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if(dmisc1 == 0)
10593 dmisc1 = 24;
10594
10595
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if(dmisc2 == 0)
10596 dmisc2 = 3;
10597
10598 //nets+760;
10599 2000 SIZEflags = d->SIZEflags;
10600
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10601 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10602 // al_trace("Enemy txsz:%i\n", txsz);
10603
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10604
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10605
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10606
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10607
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10608
1/2
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
2000 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10609 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10610
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
2000 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10612 {
10613 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10614 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10615 }
10616
10617
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2000 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2000 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10618 2000 }
10619
10620 667342 bool eTektite::animate(int32_t index)
10621 {
10622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 667342 times.
667342 if(switch_hooked) return enemy::animate(index);
10623
4/4
✓ Branch 0 taken 663848 times.
✓ Branch 1 taken 3494 times.
✓ Branch 2 taken 3494 times.
✓ Branch 3 taken 667150 times.
667342 if(fallclk||drownclk) return enemy::animate(index);
10624
2/2
✓ Branch 0 taken 15871 times.
✓ Branch 1 taken 651279 times.
667150 if(dying)
10625 15871 return Dead(index);
10626
10627
2/2
✓ Branch 0 taken 634714 times.
✓ Branch 1 taken 16565 times.
651279 if(clk==0)
10628 {
10629 16565 removearmos(x,y,ffcactivated);
10630 16565 }
10631
10632
2/2
✓ Branch 0 taken 318145 times.
✓ Branch 1 taken 333134 times.
651279 if(get_bit(quest_rules,qr_ENEMIESZAXIS))
10633 {
10634 333134 y=floor_y;
10635 333134 }
10636
10637
9/10
✓ Branch 0 taken 588492 times.
✓ Branch 1 taken 62787 times.
✓ Branch 2 taken 583908 times.
✓ Branch 3 taken 4584 times.
✓ Branch 4 taken 583908 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9135 times.
✓ Branch 7 taken 574773 times.
✓ Branch 8 taken 4678 times.
✓ Branch 9 taken 7807 times.
651279 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
10638 {
10639
4/4
✓ Branch 0 taken 6652 times.
✓ Branch 1 taken 233632 times.
✓ Branch 2 taken 150023 times.
✓ Branch 3 taken 192273 times.
582580 switch(misc)
10640 {
10641 case 0: // normal
10642
2/2
✓ Branch 0 taken 228759 times.
✓ Branch 1 taken 4873 times.
233632 if(!(zc_oldrand()%dmisc1))
10643 {
10644 4873 misc=1;
10645 4873 clk2=32;
10646 4873 }
10647
10648 233632 break;
10649
10650 case 1: // waiting to pounce
10651
2/2
✓ Branch 0 taken 142162 times.
✓ Branch 1 taken 7861 times.
150023 if(--clk2<=0)
10652 {
10653 7861 int32_t r=zc_oldrand();
10654 7861 misc=2;
10655 7861 step=0-(zslongToFix(dstep*100)); // initial speed
10656 7861 clk3=(r&1)+2; // left or right
10657 7861 clk2start=clk2=(r&31)+10; // flight time
10658
10659
2/2
✓ Branch 0 taken 6859 times.
✓ Branch 1 taken 1002 times.
7861 if(y<32) clk2+=2; // make them come down from top of screen
10660
10661
2/2
✓ Branch 0 taken 6049 times.
✓ Branch 1 taken 1812 times.
7861 if(y>112) clk2-=2; // make them go back up
10662
10663 7861 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
10664 7861 }
10665
10666 150023 break;
10667
10668 case 2: // in flight
10669 192273 move(step);
10670
10671
2/2
✓ Branch 0 taken 92728 times.
✓ Branch 1 taken 99545 times.
192273 if(step>0) //going down
10672 {
10673
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 92572 times.
92728 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
10674 {
10675 156 step=0-step;
10676 156 }
10677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92572 times.
92572 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
10678 {
10679 step=0-step;
10680 }
10681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92572 times.
92572 else if(ispitfall(x+8,y+16))
10682 {
10683 step=0-step;
10684 }
10685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92572 times.
92572 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
10686 {
10687 step=0-step;
10688 }
10689
1/2
✓ Branch 0 taken 92572 times.
✗ Branch 1 not taken.
92572 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
10690 {
10691 step=0-step;
10692 }
10693 92728 }
10694
2/2
✓ Branch 0 taken 6392 times.
✓ Branch 1 taken 93153 times.
99545 else if(step<0)
10695 {
10696
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 92934 times.
93153 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
10697 {
10698 219 step=0-step;
10699 219 }
10700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92934 times.
92934 else if(COMBOTYPE(x+8,y)==cNOENEMY)
10701 {
10702 step=0-step;
10703 }
10704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92934 times.
92934 else if(ispitfall(x+8,y))
10705 {
10706 step=0-step;
10707 }
10708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92934 times.
92934 else if(MAPFLAG(x+8,y)==mfNOENEMY)
10709 {
10710 step=0-step;
10711 }
10712
1/2
✓ Branch 0 taken 92934 times.
✗ Branch 1 not taken.
92934 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
10713 {
10714 step=0-step;
10715 }
10716 93153 }
10717
10718
2/2
✓ Branch 0 taken 95192 times.
✓ Branch 1 taken 97081 times.
192273 if(clk3==left)
10719 {
10720
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 95091 times.
95192 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
10721 {
10722 101 clk3^=1;
10723 101 }
10724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95091 times.
95091 else if(COMBOTYPE(x,y+8)==cNOENEMY)
10725 {
10726 clk3^=1;
10727 }
10728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95091 times.
95091 else if(ispitfall(x,y+8))
10729 {
10730 clk3^=1;
10731 }
10732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95091 times.
95091 else if(MAPFLAG(x,y+8)==mfNOENEMY)
10733 {
10734 clk3^=1;
10735 }
10736
1/2
✓ Branch 0 taken 95091 times.
✗ Branch 1 not taken.
95091 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
10737 {
10738 clk3^=1;
10739 }
10740 95192 }
10741 else
10742 {
10743
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 96990 times.
97081 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
10744 {
10745 91 clk3^=1;
10746 91 }
10747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96990 times.
96990 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
10748 {
10749 clk3^=1;
10750 }
10751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96990 times.
96990 else if(ispitfall(x+16,y+8))
10752 {
10753 clk3^=1;
10754 }
10755
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96990 times.
96990 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
10756 {
10757 clk3^=1;
10758 }
10759
1/2
✓ Branch 0 taken 96990 times.
✗ Branch 1 not taken.
96990 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
10760 {
10761 clk3^=1;
10762 }
10763 }
10764
10765 192273 --c;
10766
10767
4/4
✓ Branch 0 taken 57956 times.
✓ Branch 1 taken 134317 times.
✓ Branch 2 taken 126621 times.
✓ Branch 3 taken 65652 times.
192273 if(c<0 && step<zslongToFix(dstep*100))
10768 {
10769 65652 step+=zslongToFix(dmisc3*100);
10770 65652 }
10771
10772 192273 int32_t nb=get_bit(quest_rules,qr_NOBORDER) ? 16 : 0;
10773
10774
2/2
✓ Branch 0 taken 192072 times.
✓ Branch 1 taken 201 times.
192273 if(x<=16-nb) clk3=right;
10775
10776
2/2
✓ Branch 0 taken 191876 times.
✓ Branch 1 taken 397 times.
192273 if(x>=224+nb) clk3=left;
10777
10778 192273 x += (clk3==left) ? -1 : 1;
10779
10780
4/4
✓ Branch 0 taken 10761 times.
✓ Branch 1 taken 181512 times.
✓ Branch 2 taken 3326 times.
✓ Branch 3 taken 178186 times.
192273 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
10781 {
10782
4/4
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 6993 times.
✓ Branch 2 taken 265 times.
✓ Branch 3 taken 177 times.
14087 if(y>=144+nb && get_bit(quest_rules,qr_ENEMIESZAXIS))
10783 {
10784 177 step=0-step;
10785 177 y--;
10786 177 }
10787
2/2
✓ Branch 0 taken 5692 times.
✓ Branch 1 taken 1566 times.
7258 else if(zc_oldrand()%dmisc2) //land and wait
10788 {
10789 5692 clk=misc=0;
10790 5692 } //land and jump again
10791 else
10792 {
10793 1566 misc=1;
10794 1566 clk2=0;
10795 }
10796 7435 }
10797
10798 185621 break;
10799 } // switch
10800 575928 }
10801
10802
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 314843 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
647977 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10803 {
10804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
10805 {
10806 int32_t tempy = floor_y;
10807 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
10808 floor_y = y;
10809 y=tempy-fakez;
10810 old_y = y;
10811 }
10812 else
10813 {
10814 106683 int32_t tempy = floor_y;
10815
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 2353 times.
✓ Branch 3 taken 104330 times.
✓ Branch 4 taken 52359 times.
✓ Branch 5 taken 51971 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
10816 106683 floor_y = y;
10817 106683 y=tempy-z;
10818 106683 old_y = y;
10819 }
10820 106683 }
10821
10822
4/4
✓ Branch 0 taken 4584 times.
✓ Branch 1 taken 643393 times.
✓ Branch 2 taken 915 times.
✓ Branch 3 taken 3669 times.
647977 if(stunclk && (clk&31)==1)
10823 3669 clk=0;
10824
10825 647977 return enemy::animate(index);
10826 663848 }
10827
10828 205276 void eTektite::drawshadow(BITMAP *dest,bool translucent)
10829 {
10830
5/6
✓ Branch 0 taken 35720 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 35720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11386 times.
✓ Branch 5 taken 24334 times.
205276 if(z<1 && fakez<1 && get_bit(quest_rules,qr_ENEMIESZAXIS))
10831 24334 return;
10832
10833 180942 int32_t tempy=yofs;
10834 180942 int32_t fdiv = frate/4;
10835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
10837 180942 efrate:((clk>=(frate>>1))?1:0);
10838 180942 flip = 0;
10839 180942 shadowtile = wpnsbuf[spr_shadow].tile;
10840
10841
1/2
✓ Branch 0 taken 180942 times.
✗ Branch 1 not taken.
180942 if(get_bit(quest_rules,qr_NEWENEMYTILES))
10842 {
10843
2/2
✓ Branch 0 taken 68140 times.
✓ Branch 1 taken 112802 times.
180942 if(misc==0)
10844 {
10845 68140 shadowtile+=f2;
10846 68140 }
10847
2/2
✓ Branch 0 taken 50479 times.
✓ Branch 1 taken 62323 times.
112802 else if(misc!=1)
10848 62323 shadowtile+=2;
10849 180942 }
10850 else
10851 {
10852 if(misc==0)
10853 {
10854 shadowtile += f2 ? 1 : 0;
10855 }
10856 else if(misc!=1)
10857 {
10858 ++shadowtile;
10859 }
10860 }
10861
10862 180942 yofs+=8;
10863
10864
4/4
✓ Branch 0 taken 11386 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 5992 times.
✓ Branch 3 taken 5394 times.
180942 if(!get_bit(quest_rules,qr_ENEMIESZAXIS) && misc==2)
10865 {
10866
6/6
✓ Branch 0 taken 2678 times.
✓ Branch 1 taken 2716 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 5074 times.
✓ Branch 4 taken 2572 times.
✓ Branch 5 taken 2502 times.
5394 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
10867 5394 }
10868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180942 times.
180942 if(!shadow_overpit(this))
10869 180942 enemy::drawshadow(dest,translucent);
10870 180942 yofs=tempy;
10871 205276 }
10872
10873 1258976 void eTektite::draw(BITMAP *dest)
10874 {
10875 1258976 update_enemy_frame();
10876 1258976 enemy::draw(dest);
10877 1258976 }
10878
10879 606 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10880 606 {
10881
2/4
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 303 times.
✗ Branch 3 not taken.
303 step=zslongToFix(guysbuf[id&0xFFF].step*100);
10882 303 superman=1;
10883 303 dir=8;
10884 303 hxofs=1000;
10885 303 mainguy=false;
10886 303 count_enemy=false;
10887
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10888 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10889 // al_trace("Enemy txsz:%i\n", txsz);
10890
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
10891
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
10892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
10893
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
303 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
10894
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
10895
1/2
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
303 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
10896 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10897
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
10898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
303 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10899 {
10900 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
10901 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10902 }
10903
10904
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 303 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
303 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
10905 303 }
10906
10907 176141 bool eItemFairy::animate(int32_t index)
10908 {
10909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176141 times.
176141 if(switch_hooked) return enemy::animate(index);
10910
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 176141 times.
176141 if(dying)
10911 return Dead(index);
10912
10913 //if(clk>32)
10914 176141 misc=1;
10915 176141 bool w=watch;
10916 176141 watch=false;
10917 176141 variable_walk_8(misc?3:0,0,8,spw_floater);
10918 176141 watch=w;
10919
10920
2/2
✓ Branch 0 taken 848 times.
✓ Branch 1 taken 175293 times.
176141 if(clk==0)
10921 {
10922 848 removearmos(x,y,ffcactivated);
10923 848 }
10924
10925 176141 return enemy::animate(index);
10926 176141 }
10927
10928 352742 void eItemFairy::draw(BITMAP *dest)
10929 {
10930 //these are here to bypass compiler warnings about unused arguments
10931 352742 dest=dest;
10932 352742 }
10933
10934 1486 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10935 1486 {
10936 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
10937
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✓ Branch 2 taken 743 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 743 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 743 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 743 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 743 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 743 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 743 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 743 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 743 times.
✗ Branch 19 not taken.
743 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
10938 743 dir=8;
10939 743 movestatus=1;
10940 743 clk=0;
10941
1/2
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
743 step=0;
10942 //nets+720;
10943 743 SIZEflags = d->SIZEflags;
10944
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10945 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10946 // al_trace("Enemy txsz:%i\n", txsz);
10947
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10948
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
10949
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
10950
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10951
1/2
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
743 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10952
1/2
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
743 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10953 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10954
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
743 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10956 {
10957 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10958 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10959 }
10960
10961
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 743 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
743 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10962 743 }
10963
10964 225799 bool ePeahat::animate(int32_t index)
10965 {
10966
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 225799 times.
225799 if(switch_hooked) return enemy::animate(index);
10967
2/4
✓ Branch 0 taken 225799 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 225799 times.
225799 if(fallclk||drownclk) return enemy::animate(index);
10968
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 225721 times.
225799 if(slide())
10969 {
10970 78 return false;
10971 }
10972
10973
2/2
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 225235 times.
225721 if(dying)
10974 486 return Dead(index);
10975
10976
2/2
✓ Branch 0 taken 223867 times.
✓ Branch 1 taken 1368 times.
225235 if(clk==0)
10977 {
10978 1368 removearmos(x,y,ffcactivated);
10979 1368 }
10980
10981
4/4
✓ Branch 0 taken 222455 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 106275 times.
✓ Branch 3 taken 116180 times.
225235 if(stunclk==0 && clk>96)
10982 116180 misc=1;
10983
10984
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 222833 times.
225235 if(!watch)
10985
2/2
✓ Branch 0 taken 149857 times.
✓ Branch 1 taken 72976 times.
222833 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
10986
10987
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 125217 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
225235 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
10988 {
10989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
10990 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
10991 100018 }
10992
10993
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 222833 times.
✓ Branch 2 taken 1634 times.
✓ Branch 3 taken 768 times.
225235 if(watch && get_bit(quest_rules,qr_PEAHATCLOCKVULN))
10994 1634 superman=0;
10995 else
10996
2/2
✓ Branch 0 taken 217412 times.
✓ Branch 1 taken 6189 times.
223601 superman=(movestatus && !get_bit(quest_rules,qr_ENEMIESZAXIS)) ? 1 : 0;
10997 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
10998
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 29216 times.
225235 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
10999 {
11000
2/2
✓ Branch 0 taken 2777 times.
✓ Branch 1 taken 193242 times.
196019 if ( stunclk ) --stunclk;
11001 196019 }
11002 29216 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
11003 //Pretty sure this was always an error. -Z ( 14FEB2019 )
11004
11005
11006
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 225015 times.
225235 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
11007
11008 225235 return enemy::animate(index);
11009 225799 }
11010
11011 88089 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
11012 {
11013 88089 int32_t tempy=yofs;
11014 88089 flip = 0;
11015 88089 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
11016
11017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88089 times.
88089 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
11018 {
11019 yofs+=8;
11020 yofs+=int32_t(step/zslongToFix(dstep*10));
11021 }
11022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88089 times.
88089 if(!shadow_overpit(this))
11023 88089 enemy::drawshadow(dest,translucent);
11024 88089 yofs=tempy;
11025 88089 }
11026
11027 545420 void ePeahat::draw(BITMAP *dest)
11028 {
11029 545420 update_enemy_frame();
11030 545420 enemy::draw(dest);
11031 545420 }
11032
11033 817 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
11034 {
11035 817 int32_t wpnId = w->id;
11036 817 int32_t enemyHitWeapon = w->parentitem;
11037
11038
3/6
✓ Branch 0 taken 817 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 817 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 817 times.
817 if(dying || clk<0 || hclk>0)
11039 return 0;
11040
11041
4/4
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 102 times.
949 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
11042 // fire boomerang, for nailing peahats
11043
4/6
✓ Branch 0 taken 623 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 491 times.
✓ Branch 3 taken 132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
623 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
11044 593 return 0;
11045
11046 // Time for a kludge...
11047 224 int32_t s = superman;
11048 224 superman = 0;
11049 224 int32_t ret = enemy::takehit(w,realweap);
11050 224 superman = s;
11051
11052 // Anyway...
11053
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 141 times.
224 if(stunclk == 160)
11054 {
11055 141 clk2=0;
11056 141 movestatus=0;
11057 141 misc=0;
11058 141 clk=0;
11059 141 step=0;
11060 141 }
11061
11062 224 return ret;
11063 817 }
11064
11065 // auomatically kill off enemy (for rooms with ringleaders)
11066 void ePeahat::kickbucket()
11067 {
11068 hp=-1000; // don't call death_sfx()
11069 }
11070
11071 2194 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11072 2194 {
11073 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
11074
2/2
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 604 times.
1097 if(dmisc1==0)
11075 {
11076 604 misc=-1; //Line of Sight leevers
11077 604 clk-=16;
11078 604 }
11079 1097 clk3 = 0;
11080 //nets+1460;
11081
1/2
✓ Branch 0 taken 1097 times.
✗ Branch 1 not taken.
1097 temprule=(get_bit(quest_rules,qr_NEWENEMYTILES)) != 0;
11082 1097 submerged = false;
11083 1097 SIZEflags = d->SIZEflags;
11084
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11085 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11086 // al_trace("Enemy txsz:%i\n", txsz);
11087
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11090
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11091
1/2
✓ Branch 0 taken 1097 times.
✗ Branch 1 not taken.
1097 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11092
1/2
✓ Branch 0 taken 1097 times.
✗ Branch 1 not taken.
1097 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11093 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11094
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
1097 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11096 {
11097 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11098 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11099 }
11100
11101
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1097 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1097 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11102 1097 }
11103
11104 bool eLeever::isSubmerged() const
11105 {
11106 Z_scripterrlog("misc is: %d\n", misc);
11107 return misc <= 0;
11108
11109 }
11110
11111 320425 bool eLeever::animate(int32_t index)
11112 {
11113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 320425 times.
320425 if(switch_hooked) return enemy::animate(index);
11114
2/4
✓ Branch 0 taken 320425 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 320425 times.
320425 if(fallclk||drownclk)
11115 {
11116 return enemy::animate(index);
11117 }
11118
2/2
✓ Branch 0 taken 12312 times.
✓ Branch 1 taken 308113 times.
320425 if(dying)
11119 12312 return Dead(index);
11120
11121
2/2
✓ Branch 0 taken 291344 times.
✓ Branch 1 taken 16769 times.
308113 if(clk==0)
11122 {
11123 16769 removearmos(x,y,ffcactivated);
11124 16769 }
11125
11126
4/4
✓ Branch 0 taken 255376 times.
✓ Branch 1 taken 52737 times.
✓ Branch 2 taken 1847 times.
✓ Branch 3 taken 253529 times.
308113 if(clk>=0 && !slide())
11127 {
11128 // switch(d->misc1)
11129
2/2
✓ Branch 0 taken 90190 times.
✓ Branch 1 taken 163339 times.
253529 switch(dmisc1)
11130 {
11131 case 0: //line of sight
11132 case 2:
11133
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 30948 times.
✓ Branch 2 taken 8626 times.
✓ Branch 3 taken 11370 times.
✓ Branch 4 taken 5067 times.
✓ Branch 5 taken 30855 times.
✓ Branch 6 taken 1287 times.
✓ Branch 7 taken 2037 times.
90190 switch(misc) //is this leever active
11134 {
11135 case -1: //submerged
11136 {
11137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30948 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30948 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
11138
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 23339 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
30948 if((dmisc1==2)&&(zc_oldrand()&255))
11139 {
11140 7582 break;
11141 }
11142
11143 23366 int32_t active=0;
11144
11145
2/2
✓ Branch 0 taken 130512 times.
✓ Branch 1 taken 23366 times.
153878 for(int32_t i=0; i<guys.Count(); i++)
11146 {
11147
4/4
✓ Branch 0 taken 113163 times.
✓ Branch 1 taken 17349 times.
✓ Branch 2 taken 67249 times.
✓ Branch 3 taken 45914 times.
130512 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
11148 {
11149 45914 ++active;
11150 45914 }
11151 130512 }
11152
11153
2/2
✓ Branch 0 taken 22791 times.
✓ Branch 1 taken 575 times.
23366 if(active<((dmisc1==2)?1:2))
11154 {
11155 575 misc=0; //activate this one
11156 575 clk3=1; //This needs to be set so that it knows that it's being emerged of it's own will and not because it got stunned.
11157 575 }
11158 }
11159 23366 break;
11160
11161 case 0:
11162 {
11163
11164
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8626 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8626 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11165 {
11166 misc=1;
11167 clk2=0;
11168 }
11169
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 8590 times.
8626 else if (clk3<=0)
11170 {
11171 36 misc = -1;
11172 36 break;
11173 }
11174 8590 int32_t s=0;
11175
11176
2/2
✓ Branch 0 taken 54807 times.
✓ Branch 1 taken 8590 times.
63397 for(int32_t i=0; i<guys.Count(); i++)
11177 {
11178
4/4
✓ Branch 0 taken 25493 times.
✓ Branch 1 taken 29314 times.
✓ Branch 2 taken 23967 times.
✓ Branch 3 taken 1526 times.
54807 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
11179 {
11180 1526 ++s;
11181 1526 }
11182 54807 }
11183
11184
2/2
✓ Branch 0 taken 1526 times.
✓ Branch 1 taken 7064 times.
8590 if(s>0)
11185 {
11186 1526 break;
11187 }
11188
11189 7064 int32_t d2=zc_oldrand()&1;
11190
11191
2/2
✓ Branch 0 taken 1399 times.
✓ Branch 1 taken 5665 times.
7064 if(HeroDir()>=left)
11192 {
11193 5665 d2+=2;
11194 5665 }
11195
11196
4/4
✓ Branch 0 taken 6610 times.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 220 times.
✓ Branch 3 taken 6390 times.
7064 if(canplace(d2) || canplace(d2^1))
11197 {
11198 674 misc=1;
11199 674 clk2=0;
11200 674 clk=0;
11201 674 }
11202 }
11203 7064 break;
11204
11205 case 1:
11206
11207
3/8
✓ Branch 0 taken 10706 times.
✓ Branch 1 taken 664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10706 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11370 if(++clk2>16||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
11208
11209 11370 break;
11210
11211 case 2:
11212
11213
3/8
✓ Branch 0 taken 4451 times.
✓ Branch 1 taken 616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4451 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
5067 if(++clk2>24||(!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
11214
11215 5067 break;
11216
11217 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
11218 case 3:
11219
11220
5/6
✓ Branch 0 taken 28833 times.
✓ Branch 1 taken 2022 times.
✓ Branch 2 taken 28833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 914 times.
✓ Branch 5 taken 27919 times.
30855 if(stunclk || frozenclock || watch) break;
11221
11222
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 27861 times.
27919 if(scored) dir^=1;
11223
11224
2/2
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 27770 times.
27919 if(!canmove(dir,false)) misc=4;
11225 27770 else move(zslongToFix(dstep*100));
11226
11227 27919 break;
11228
11229 case 4:
11230
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1287 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1287 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
11231
2/2
✓ Branch 0 taken 1150 times.
✓ Branch 1 taken 137 times.
1287 if(--clk2<=16)
11232 {
11233 137 misc=5;
11234 137 clk=8;
11235 137 }
11236
11237 1287 break;
11238
11239 case 5:
11240
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2037 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2037 if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
11241
2/2
✓ Branch 0 taken 1913 times.
✓ Branch 1 taken 124 times.
2037 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
11242
11243 2037 break;
11244 } // switch(misc)
11245
11246 90190 break;
11247
11248 default: //random
11249 // step=d->misc3/100.0;
11250
11251 163339 step=zslongToFix(dmisc3*100);
11252
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 163339 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
163339 if (get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
11253 else if (!get_bit(quest_rules, qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
11254 {
11255 if (clk2 < 48) clk2+=2;
11256 if (clk2 >= 300) clk2-=2;
11257 }
11258
11259
2/2
✓ Branch 0 taken 18655 times.
✓ Branch 1 taken 144684 times.
163339 if(clk2<32) misc=1;
11260
2/2
✓ Branch 0 taken 9384 times.
✓ Branch 1 taken 135300 times.
144684 else if(clk2<48) misc=2;
11261
2/2
✓ Branch 0 taken 95420 times.
✓ Branch 1 taken 39880 times.
135300 else if(clk2<300)
11262 {
11263 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
11264 {
11265 fix_coords();
11266 }*/
11267 95420 misc=3;
11268 95420 step = zslongToFix(dstep*100);
11269 95420 }
11270
2/2
✓ Branch 0 taken 3366 times.
✓ Branch 1 taken 36514 times.
39880 else if(clk2<316) misc=2;
11271
2/2
✓ Branch 0 taken 17645 times.
✓ Branch 1 taken 18869 times.
36514 else if(clk2<412) misc=1;
11272
2/2
✓ Branch 0 taken 18731 times.
✓ Branch 1 taken 138 times.
18869 else if(clk2<540)
11273 {
11274 18731 misc=0;
11275 18731 step=0;
11276 18731 }
11277 138 else clk2=0;
11278
11279
2/2
✓ Branch 0 taken 162764 times.
✓ Branch 1 taken 575 times.
163339 if(clk2==48) clk=0;
11280
11281 // variable_walk(d->rate, d->homing, 0);
11282 163339 variable_walk(rate, homing, 0);
11283 163339 } // switch(dmisc1)
11284 253529 }
11285
11286 308113 hxofs=(misc>=2)?0:1000;
11287 308113 return enemy::animate(index);
11288 320425 }
11289
11290 13674 bool eLeever::canplace(int32_t d2)
11291 {
11292 13674 int32_t nx=HeroX();
11293 13674 int32_t ny=HeroY();
11294
11295
2/2
✓ Branch 0 taken 2639 times.
✓ Branch 1 taken 11035 times.
13674 if(d2<left) ny&=0xF0;
11296 11035 else nx&=0xF0;
11297
11298
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✓ Branch 2 taken 1336 times.
✓ Branch 3 taken 5503 times.
✓ Branch 4 taken 5532 times.
13674 switch(d2)
11299 {
11300 // case up: ny-=((d->misc1==0)?32:48); break;
11301 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
11302 // case left: nx-=((d->misc1==0)?32:48); break;
11303 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
11304 case up:
11305
2/2
✓ Branch 0 taken 1275 times.
✓ Branch 1 taken 28 times.
1303 ny-=((dmisc1==0||dmisc1==2)?32:48);
11306 1303 break;
11307
11308 case down:
11309
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 1305 times.
1336 ny+=((dmisc1==0||dmisc1==2)?32:48);
11310
11311
4/4
✓ Branch 0 taken 776 times.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 767 times.
✓ Branch 3 taken 9 times.
1336 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
11312
11313 1336 break;
11314
11315 case left:
11316
2/2
✓ Branch 0 taken 4903 times.
✓ Branch 1 taken 600 times.
5503 nx-=((dmisc1==0||dmisc1==2)?32:48);
11317 5503 break;
11318
11319 case right:
11320
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 4937 times.
5532 nx+=((dmisc1==0||dmisc1==2)?32:48);
11321
11322
4/4
✓ Branch 0 taken 4160 times.
✓ Branch 1 taken 1372 times.
✓ Branch 2 taken 3605 times.
✓ Branch 3 taken 555 times.
5532 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
11323
11324 5532 break;
11325 }
11326
11327
4/4
✓ Branch 0 taken 6088 times.
✓ Branch 1 taken 7586 times.
✓ Branch 2 taken 2565 times.
✓ Branch 3 taken 3523 times.
13674 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
11328 10151 return false;
11329
11330
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 3241 times.
3523 if(d2>=left)
11331
4/4
✓ Branch 0 taken 1071 times.
✓ Branch 1 taken 2170 times.
✓ Branch 2 taken 2849 times.
✓ Branch 3 taken 392 times.
3241 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
11332 2849 return false;
11333
11334 674 x=nx;
11335 674 y=ny;
11336 674 dir=d2^1;
11337 674 return true;
11338 13674 }
11339
11340 321245 void eLeever::draw(BITMAP *dest)
11341 {
11342 // cs=d->cset;
11343 321245 cs=dcset;
11344 321245 update_enemy_frame();
11345
2/4
✓ Branch 0 taken 321245 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321245 times.
321245 if(!fallclk&&!drownclk)
11346 {
11347
2/2
✓ Branch 0 taken 209269 times.
✓ Branch 1 taken 111976 times.
321245 switch(misc)
11348 {
11349 case -1:
11350 case 0:
11351 111976 return;
11352 }
11353 209269 }
11354
11355 209269 enemy::draw(dest);
11356 321245 }
11357
11358 754 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11359 754 {
11360 //zprint2("eWallM::eWallM\n");
11361 377 hashero=false;
11362 //nets+1000;
11363 377 SIZEflags = d->SIZEflags;
11364
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11365 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11366 // al_trace("Enemy txsz:%i\n", txsz);
11367
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11368
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11369
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11371
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11372
1/2
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
377 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11373 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11374
1/4
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
377 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11376 {
11377 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11378 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11379 }
11380
11381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 377 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
377 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11382 377 }
11383
11384 249384 bool eWallM::animate(int32_t index)
11385 {
11386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 249384 times.
249384 if(switch_hooked) return enemy::animate(index);
11387
2/4
✓ Branch 0 taken 249384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 249384 times.
249384 if(fallclk||drownclk)
11388 {
11389 return enemy::animate(index);
11390 }
11391
2/2
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 244596 times.
249384 if(dying)
11392 4788 return Dead(index);
11393
11394
2/2
✓ Branch 0 taken 228902 times.
✓ Branch 1 taken 15694 times.
244596 if(clk==0)
11395 {
11396 15694 removearmos(x,y,ffcactivated);
11397 15694 }
11398
11399 244596 hxofs=1000;
11400
2/2
✓ Branch 0 taken 62103 times.
✓ Branch 1 taken 182493 times.
244596 if(misc==0) //inside wall, ready to spawn?
11401 {
11402 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
11403 //zprint2("frame is: %d\n",frame);
11404 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
11405
4/4
✓ Branch 0 taken 120227 times.
✓ Branch 1 taken 62266 times.
✓ Branch 2 taken 6686 times.
✓ Branch 3 taken 113541 times.
182493 if(frame-wallm_load_clk>80 && clk>=0)
11406 {
11407 //zprint2("getting wall\n");
11408 113541 int32_t wall=hero_on_wall();
11409 //zprint2("Wallmaster wall is %d\n",wall);
11410 113541 int32_t wallm_cnt=0;
11411
11412
2/2
✓ Branch 0 taken 898450 times.
✓ Branch 1 taken 113541 times.
1011991 for(int32_t i=0; i<guys.Count(); i++)
11413
2/2
✓ Branch 0 taken 346283 times.
✓ Branch 1 taken 552167 times.
1450617 if(((enemy*)guys.spr(i))->family==eeWALLM)
11414 {
11415 552167 int32_t m=((enemy*)guys.spr(i))->misc;
11416
11417
4/4
✓ Branch 0 taken 23383 times.
✓ Branch 1 taken 528784 times.
✓ Branch 2 taken 13566 times.
✓ Branch 3 taken 9817 times.
552167 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
11418 {
11419 9817 ++wallm_cnt;
11420 9817 }
11421 552167 }
11422
11423
2/2
✓ Branch 0 taken 113164 times.
✓ Branch 1 taken 377 times.
113541 if(wall>0)
11424 {
11425 377 --wall;
11426 377 misc=1; //emerging from the wall?
11427 //zprint2("Wallmaster is emerging\n");
11428 377 clk2=0;
11429 377 clk3=wall^1;
11430 377 wallm_load_clk=frame;
11431
11432
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 150 times.
377 if(wall<=down)
11433 {
11434
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(HeroDir()==left)
11435 35 dir=right;
11436 else
11437 192 dir=left;
11438 227 }
11439 else
11440 {
11441
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 115 times.
150 if(HeroDir()==up)
11442 35 dir=down;
11443 else
11444 115 dir=up;
11445 }
11446
11447
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 103 times.
✓ Branch 4 taken 47 times.
377 switch(wall)
11448 {
11449 case up:
11450 125 y=0;
11451 125 break;
11452
11453 case down:
11454 102 y=160;
11455 102 break;
11456
11457 case left:
11458 103 x=0;
11459 103 break;
11460
11461 case right:
11462 47 x=240;
11463 47 break;
11464 }
11465
11466 //zprint2("Wallmaster (p1) x is %d\n",x);
11467 //zprint2("Wallmaster (p1) y is %d\n",y);
11468
11469
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 192 times.
✓ Branch 4 taken 35 times.
377 switch(dir)
11470 {
11471 case up:
11472 115 y=(HeroY()+48-(wallm_cnt&1)*12);
11473 115 flip=wall&1;
11474 115 break;
11475
11476 case down:
11477 35 y=(HeroY()-48+(wallm_cnt&1)*12);
11478 35 flip=((wall&1)^1)+2;
11479 35 break;
11480
11481 case left:
11482 192 x=(HeroX()+48-(wallm_cnt&1)*12);
11483 192 flip=(wall==up?2:0)+1;
11484 192 break;
11485
11486 case right:
11487 35 x=(HeroX()-48+(wallm_cnt&1)*12);
11488 35 flip=(wall==up?2:0);
11489 35 break;
11490 }
11491
11492 //zprint2("Wallmaster (p2) x is %d\n",x);
11493 //zprint2("Wallmaster (p2) y is %d\n",y);
11494 377 }
11495 113541 }
11496 182493 }
11497 else
11498 62103 wallm_crawl();
11499
11500 244596 return enemy::animate(index);
11501 249384 }
11502
11503 62103 void eWallM::wallm_crawl()
11504 {
11505 62103 bool w=watch;
11506 62103 hxofs=0;
11507
11508
2/2
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 61663 times.
62103 if(slide())
11509 {
11510 440 return;
11511 }
11512
11513 // if(dying || watch || (!hashero && stunclk))
11514
6/8
✓ Branch 0 taken 61663 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61374 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 47704 times.
✓ Branch 5 taken 13670 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 47704 times.
61663 if(dying || (!hashero && ( stunclk || frozenclock )))
11515 {
11516 13670 return;
11517 }
11518
11519 47993 watch=false;
11520 47993 ++clk2;
11521 // Misc1: slightly different movement
11522 //zprint2("wallmaster crawl\n");
11523 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
11524 47993 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
11525
11526 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
11527 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
11528 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
11529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47993 times.
47993 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
11530 //zprint2("wallmaster crawl misc is: %d\n", misc);
11531
5/6
✓ Branch 0 taken 2791 times.
✓ Branch 1 taken 45202 times.
✓ Branch 2 taken 2140 times.
✓ Branch 3 taken 651 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2140 times.
47993 if(w&&misc>=3&&misc<=5)
11532 {
11533 2140 --clk2;
11534 2140 }
11535
11536
4/4
✓ Branch 0 taken 20291 times.
✓ Branch 1 taken 22042 times.
✓ Branch 2 taken 5567 times.
✓ Branch 3 taken 93 times.
47993 switch(misc)
11537 {
11538 case 1:
11539 case 2:
11540 22042 zc_swap(dir,clk3);
11541 22042 move(step);
11542 22042 zc_swap(dir,clk3);
11543 22042 break;
11544
11545 case 3:
11546 case 4:
11547 case 5:
11548
2/2
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 18151 times.
20291 if(w)
11549 {
11550 2140 watch=w;
11551 2140 return;
11552 }
11553
11554 18151 move(step);
11555 18151 break;
11556
11557 case 6:
11558 case 7:
11559 5567 zc_swap(dir,clk3);
11560 5567 dir^=1;
11561 5567 move(step);
11562 5567 dir^=1;
11563 5567 zc_swap(dir,clk3);
11564 5567 break;
11565
11566 default:
11567 93 misc=0;
11568 93 break;
11569 }
11570
11571 45853 watch=w;
11572 62103 }
11573
11574 3 void eWallM::grabhero()
11575 {
11576 3 hashero=true;
11577 3 superman=1;
11578 3 }
11579
11580 249671 void eWallM::draw(BITMAP *dest)
11581 {
11582 249671 dummy_bool[1]=hashero;
11583 249671 update_enemy_frame();
11584
11585
4/6
✓ Branch 0 taken 182490 times.
✓ Branch 1 taken 67181 times.
✓ Branch 2 taken 182490 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 182490 times.
249671 if(misc>0 || fallclk||drownclk)
11586 {
11587 67181 masked_draw(dest,16,playing_field_offset+16,224,144);
11588 67181 }
11589
11590 // enemy::draw(dest);
11591 // tile = clk&8 ? 128:129;
11592 249671 }
11593
11594 bool eWallM::isSubmerged() const
11595 {
11596 return ( !misc );
11597 }
11598
11599 1092 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11600 1092 {
11601
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 ox=x; //original x
11602
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 oy=y; //original y
11603
3/4
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 480 times.
546 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11604 {
11605
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
66 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11606 66 }
11607
11608 546 mainguy=false;
11609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11610 //nets+420;
11611 546 dummy_int[1]=0;
11612 546 SIZEflags = d->SIZEflags;
11613
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11614 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11615 // al_trace("Enemy txsz:%i\n", txsz);
11616
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11617
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11619
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11620
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11621
1/2
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
546 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11622 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11623
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
546 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11625 {
11626 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11627 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11628 }
11629
11630
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 546 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
546 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11631 546 }
11632
11633 399417 bool eTrap::animate(int32_t index)
11634 {
11635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399417 times.
399417 if(switch_hooked) return enemy::animate(index);
11636
2/4
✓ Branch 0 taken 399417 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 399417 times.
399417 if(fallclk||drownclk) return enemy::animate(index);
11637
2/2
✓ Branch 0 taken 391777 times.
✓ Branch 1 taken 7640 times.
399417 if(clk<0)
11638 7640 return enemy::animate(index);
11639
11640
2/2
✓ Branch 0 taken 367022 times.
✓ Branch 1 taken 24755 times.
391777 if(clk==0)
11641 {
11642 24755 removearmos(x,y,ffcactivated);
11643 24755 }
11644
11645
2/2
✓ Branch 0 taken 99581 times.
✓ Branch 1 taken 292196 times.
391777 if(misc==0) // waiting
11646 {
11647 292196 ox = x;
11648 292196 oy = y;
11649 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11650 292196 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11651
11652
4/4
✓ Branch 0 taken 95582 times.
✓ Branch 1 taken 196614 times.
✓ Branch 2 taken 57428 times.
✓ Branch 3 taken 38154 times.
292196 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
11653 {
11654 38154 dir=down;
11655 38154 }
11656
4/4
✓ Branch 0 taken 170626 times.
✓ Branch 1 taken 83416 times.
✓ Branch 2 taken 57428 times.
✓ Branch 3 taken 113198 times.
254042 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
11657 {
11658 113198 dir=right;
11659 113198 }
11660
4/4
✓ Branch 0 taken 88162 times.
✓ Branch 1 taken 52682 times.
✓ Branch 2 taken 57428 times.
✓ Branch 3 taken 30734 times.
140844 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
11661 {
11662 30734 dir=up;
11663 30734 }
11664 else
11665 {
11666 110110 dir=left;
11667 }
11668
11669 292196 int32_t d2=lined_up(15,true);
11670
11671
4/4
✓ Branch 0 taken 100586 times.
✓ Branch 1 taken 191610 times.
✓ Branch 2 taken 539099 times.
✓ Branch 3 taken 246903 times.
475909 if(((d2<left || d2 > right) && (dmisc1==1)) ||
11672
2/2
✓ Branch 0 taken 96443 times.
✓ Branch 1 taken 164472 times.
246903 ((d2>down) && (dmisc1==2)) ||
11673
2/2
✓ Branch 0 taken 90963 times.
✓ Branch 1 taken 86481 times.
164472 ((d2>right) && (!dmisc1)) ||
11674
2/2
✓ Branch 0 taken 183713 times.
✓ Branch 1 taken 38215 times.
177444 ((d2<l_up) && (dmisc1==4)) ||
11675
3/4
✓ Branch 0 taken 183713 times.
✓ Branch 1 taken 145498 times.
✓ Branch 2 taken 183713 times.
✗ Branch 3 not taken.
38215 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
11676
3/4
✓ Branch 0 taken 183713 times.
✓ Branch 1 taken 38215 times.
✓ Branch 2 taken 183713 times.
✗ Branch 3 not taken.
145498 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
11677 {
11678 1186681 d2=-1;
11679 1186681 }
11680
11681
4/4
✓ Branch 0 taken 8772 times.
✓ Branch 1 taken 137926 times.
✓ Branch 2 taken 7990 times.
✓ Branch 3 taken 782 times.
146698 if(d2!=-1 && trapmove(d2))
11682 {
11683 782 dir=d2;
11684 782 misc=1;
11685 782 clk2=(dir==down)?3:0;
11686 782 }
11687 146698 }
11688
11689
2/2
✓ Branch 0 taken 218874 times.
✓ Branch 1 taken 27405 times.
246279 if(misc==1) // charging
11690 {
11691 27405 clk2=(clk2+1)&3;
11692 27405 step=(clk2==3)?1:2;
11693
11694
4/4
✓ Branch 0 taken 27373 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 694 times.
✓ Branch 3 taken 26679 times.
27405 if(!trapmove(dir) || clip())
11695 {
11696 726 misc=2;
11697
11698
1/2
✓ Branch 0 taken 726 times.
✗ Branch 1 not taken.
726 if(dir<l_up)
11699 {
11700 726 dir=dir^1;
11701 726 }
11702 else
11703 {
11704 dir=dir^3;
11705 }
11706 726 }
11707 else
11708 {
11709 26679 sprite::move(step);
11710 }
11711 27405 }
11712
11713
2/2
✓ Branch 0 taken 172595 times.
✓ Branch 1 taken 73684 times.
246279 if(misc==2) // retreating
11714 {
11715 73684 step=(++clk2&1)?1:0;
11716
11717
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 10722 times.
✓ Branch 2 taken 27408 times.
✓ Branch 3 taken 8999 times.
✓ Branch 4 taken 26555 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
73684 switch(dir)
11718 {
11719 case up:
11720
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 10622 times.
10722 if(int32_t(y)<=oy) goto trap_rest;
11721 10622 else sprite::move(step);
11722
11723 10622 break;
11724
11725 case left:
11726
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 27252 times.
27408 if(int32_t(x)<=ox) goto trap_rest;
11727 27252 else sprite::move(step);
11728
11729 27252 break;
11730
11731 case down:
11732
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 8905 times.
8999 if(int32_t(y)>=oy) goto trap_rest;
11733 8905 else sprite::move(step);
11734
11735 8905 break;
11736
11737 case right:
11738
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 26392 times.
26555 if(int32_t(x)>=ox) goto trap_rest;
11739 26392 else sprite::move(step);
11740
11741 26392 break;
11742
11743 case l_up:
11744 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
11745 else sprite::move(step);
11746
11747 break;
11748
11749 case r_up:
11750 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
11751 else sprite::move(step);
11752
11753 break;
11754
11755 case l_down:
11756 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
11757 else sprite::move(step);
11758
11759 break;
11760
11761 case r_down:
11762 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
11763 else sprite::move(step);
11764
11765 break;
11766 trap_rest:
11767 {
11768 513 x=ox;
11769 513 y=oy;
11770 513 misc=0;
11771 }
11772 513 }
11773 73684 }
11774
11775 246279 return enemy::animate(index);
11776 253919 }
11777
11778 36177 bool eTrap::trapmove(int32_t ndir)
11779 {
11780
2/2
✓ Branch 0 taken 21910 times.
✓ Branch 1 taken 14267 times.
36177 if(get_bit(quest_rules,qr_MEANTRAPS))
11781 {
11782
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 20570 times.
21910 if(tmpscr->flags2&fFLOATTRAPS)
11783 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
11784
11785 20570 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
11786 }
11787
11788
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
11789 2766 return false;
11790
11791
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
11792 return false;
11793
11794
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
11795 return false;
11796
11797
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
11798 return false;
11799
11800
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
11801 718 return false;
11802
11803
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
11804 488 return false;
11805
11806
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
11807 return false;
11808
11809
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
11810 return false;
11811
11812
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
11813 return false;
11814
11815
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
11816 return false;
11817
11818 10295 return true;
11819 36177 }
11820
11821 27373 bool eTrap::clip()
11822 {
11823
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 26633 times.
27373 if(get_bit(quest_rules,qr_MEANPLACEDTRAPS))
11824 {
11825
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 118 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
740 switch(dir)
11826 {
11827 case up:
11828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(y<=0) return true;
11829
11830 252 break;
11831
11832 case down:
11833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 252 times.
252 if(y>=160) return true;
11834
11835 252 break;
11836
11837 case left:
11838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(x<=0) return true;
11839
11840 118 break;
11841
11842 case right:
11843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
118 if(x>=240) return true;
11844
11845 118 break;
11846
11847 case l_up:
11848 if(y<=0||x<=0) return true;
11849
11850 break;
11851
11852 case l_down:
11853 if(y>=160||x<=0) return true;
11854
11855 break;
11856
11857 case r_up:
11858 if(y<=0||x>=240) return true;
11859
11860 break;
11861
11862 case r_down:
11863 if(y>=160||x>=240) return true;
11864
11865 break;
11866 }
11867
11868 740 return false;
11869 }
11870 else
11871 {
11872
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3120 times.
✓ Branch 2 taken 3491 times.
✓ Branch 3 taken 9764 times.
✓ Branch 4 taken 10258 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
26633 switch(dir)
11873 {
11874 case up:
11875
4/4
✓ Branch 0 taken 3066 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 2946 times.
✓ Branch 3 taken 120 times.
3120 if(oy>80 && y<=86) return true;
11876
11877 3000 break;
11878
11879 case down:
11880
4/4
✓ Branch 0 taken 3410 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3282 times.
✓ Branch 3 taken 128 times.
3491 if(oy<80 && y>=80) return true;
11881
11882 3363 break;
11883
11884 case left:
11885
4/4
✓ Branch 0 taken 9674 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 9455 times.
✓ Branch 3 taken 219 times.
9764 if(ox>128 && x<=124) return true;
11886
11887 9545 break;
11888
11889 case right:
11890
3/4
✓ Branch 0 taken 10258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10031 times.
✓ Branch 3 taken 227 times.
10258 if(ox<120 && x>=116) return true;
11891
11892 10031 break;
11893
11894 case l_up:
11895 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
11896
11897 break;
11898
11899 case l_down:
11900 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
11901
11902 break;
11903
11904 case r_up:
11905 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
11906
11907 break;
11908
11909 case r_down:
11910 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
11911
11912 break;
11913 }
11914
11915 25939 return false;
11916 }
11917 27373 }
11918
11919 399725 void eTrap::draw(BITMAP *dest)
11920 {
11921 399725 update_enemy_frame();
11922 399725 enemy::draw(dest);
11923 399725 }
11924
11925 2279 int32_t eTrap::takehit(weapon*,weapon*)
11926 {
11927 2279 return 0;
11928 }
11929
11930 238 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11931 238 {
11932 119 lasthit=-1;
11933 119 lasthitclk=0;
11934 119 mainguy=false;
11935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
11936
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 step=2;
11937
3/6
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
11938 {
11939
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 dir=(x<=112)?right:left;
11940 48 }
11941 else
11942 {
11943
2/4
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
71 dir=(y<=72)?down:up;
11944 }
11945
11946
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
119 if(get_bit(quest_rules,qr_TRAPPOSFIX))
11947 {
11948 yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
11949 }
11950
11951 //nets+((id==eTRAP_LR)?540:520);
11952 119 dummy_int[1]=0;
11953 119 SIZEflags = d->SIZEflags;
11954
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11955 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
11956 // al_trace("Enemy txsz:%i\n", txsz);
11957
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11958
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
11959
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
11960
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
11961
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11962
1/2
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
119 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11963 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
11964
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11965
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
119 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11966 {
11967 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11968 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11969 }
11970
11971
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
119 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11972 119 }
11973
11974 66423 bool eTrap2::animate(int32_t index)
11975 {
11976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66423 times.
66423 if(switch_hooked) return enemy::animate(index);
11977
2/4
✓ Branch 0 taken 66423 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66423 times.
66423 if(fallclk||drownclk) return enemy::animate(index);
11978
2/2
✓ Branch 0 taken 64757 times.
✓ Branch 1 taken 1666 times.
66423 if(clk<0)
11979 1666 return enemy::animate(index);
11980
11981
2/2
✓ Branch 0 taken 4108 times.
✓ Branch 1 taken 60649 times.
64757 if(clk==0)
11982 {
11983 4108 removearmos(x,y,ffcactivated);
11984 4108 }
11985
11986
2/2
✓ Branch 0 taken 60365 times.
✓ Branch 1 taken 4392 times.
64757 if(!get_bit(quest_rules,qr_PHANTOMPLACEDTRAPS))
11987 {
11988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
11989 {
11990 --lasthitclk;
11991 }
11992 else
11993 {
11994 4392 lasthit=-1;
11995 }
11996
11997 4392 bool hitenemy=false;
11998
11999
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
12000 {
12001
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
12002 {
12003
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
12004 {
12005 lasthit=j;
12006 lasthitclk=10;
12007 hitenemy=true;
12008 guys.spr(j)->lasthit=index;
12009 guys.spr(j)->lasthitclk=10;
12010 // guys.spr(j)->dir=guys.spr(j)->dir^1;
12011 }
12012 52704 }
12013 57096 }
12014
12015
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
12016 {
12017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
12018 {
12019 48 lasthit=-1;
12020 48 lasthitclk=0;
12021 48 }
12022
12023
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_bit(quest_rules,qr_MORESOUNDS))
12024 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12025
12026 48 dir=dir^1;
12027 48 }
12028
12029 4392 sprite::move(step);
12030 4392 }
12031 else
12032 {
12033
3/4
✓ Branch 0 taken 58983 times.
✓ Branch 1 taken 1382 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58983 times.
60365 if(!trapmove(dir) || clip())
12034 {
12035
1/2
✓ Branch 0 taken 1382 times.
✗ Branch 1 not taken.
1382 if(get_bit(quest_rules,qr_MORESOUNDS))
12036 sfx(WAV_ZN1TAP,pan(int32_t(x)));
12037
12038 1382 dir=dir^1;
12039 1382 }
12040
12041 60365 sprite::move(step);
12042 }
12043
12044 64757 return enemy::animate(index);
12045 66423 }
12046
12047 64805 bool eTrap2::trapmove(int32_t ndir)
12048 {
12049
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 62927 times.
64805 if(tmpscr->flags2&fFLOATTRAPS)
12050 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
12051
12052 62927 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
12053 64805 }
12054
12055 63327 bool eTrap2::clip()
12056 {
12057
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18583 times.
✓ Branch 2 taken 18827 times.
✓ Branch 3 taken 12915 times.
✓ Branch 4 taken 13002 times.
63327 switch(dir)
12058 {
12059 case up:
12060
1/2
✓ Branch 0 taken 18583 times.
✗ Branch 1 not taken.
18583 if(y<=0) return true;
12061
12062 18583 break;
12063
12064 case down:
12065
1/2
✓ Branch 0 taken 18827 times.
✗ Branch 1 not taken.
18827 if(y>=160) return true;
12066
12067 18827 break;
12068
12069 case left:
12070
1/2
✓ Branch 0 taken 12915 times.
✗ Branch 1 not taken.
12915 if(x<=0) return true;
12071
12072 12915 break;
12073
12074 case right:
12075
1/2
✓ Branch 0 taken 13002 times.
✗ Branch 1 not taken.
13002 if(x>=240) return true;
12076
12077 13002 break;
12078 }
12079
12080 63327 return false;
12081 63327 }
12082
12083 66433 void eTrap2::draw(BITMAP *dest)
12084 {
12085 66433 update_enemy_frame();
12086 66433 enemy::draw(dest);
12087 66433 }
12088
12089 526 int32_t eTrap2::takehit(weapon*,weapon*)
12090 {
12091 526 return 0;
12092 }
12093
12094 332 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12095 332 {
12096 //do not show "enemy appering" anim -DD
12097 166 clk=0;
12098 166 mainguy=false;
12099 166 clk2=-14;
12100 //Enemy Editor Size Tab
12101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12102 166 else hxofs = -2;
12103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12104 166 else hyofs = -2;
12105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12106 166 else hxsz = 20;
12107
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12108 166 else hysz=20;
12109
12110
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12111
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12113
1/4
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12115 {
12116 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12117 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12118 }
12119
12120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
166 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12121 //nets+1640;
12122 166 }
12123
12124 51400 bool eRock::animate(int32_t index)
12125 {
12126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51400 times.
51400 if(switch_hooked) return enemy::animate(index);
12127
2/4
✓ Branch 0 taken 51400 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51400 times.
51400 if(fallclk||drownclk) return enemy::animate(index);
12128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51400 times.
51400 if(dying)
12129 return Dead(index);
12130
12131
2/2
✓ Branch 0 taken 48055 times.
✓ Branch 1 taken 3345 times.
51400 if(clk==0)
12132 {
12133 3345 removearmos(x,y,ffcactivated);
12134 3345 }
12135
12136
2/2
✓ Branch 0 taken 51106 times.
✓ Branch 1 taken 294 times.
51400 if(++clk2==0) // start it
12137 {
12138 294 x=zc_oldrand()&0xF0;
12139 294 y=0;
12140 294 clk3=0;
12141 294 clk2=zc_oldrand()&15;
12142 294 }
12143
12144
2/2
✓ Branch 0 taken 9272 times.
✓ Branch 1 taken 42128 times.
51400 if(clk2>16) // move it
12145 {
12146
2/2
✓ Branch 0 taken 40673 times.
✓ Branch 1 taken 1455 times.
42128 if(clk3<=0) // start bounce
12147 {
12148 1455 dir=zc_oldrand()&1;
12149
12150
2/2
✓ Branch 0 taken 1286 times.
✓ Branch 1 taken 169 times.
1455 if(x<32) dir=1;
12151
12152
2/2
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 122 times.
1455 if(x>208) dir=0;
12153 1455 }
12154
12155
2/2
✓ Branch 0 taken 40778 times.
✓ Branch 1 taken 1350 times.
42128 if(clk3<13+16)
12156 {
12157 40778 x += dir ? 1 : -1; //right, left
12158 40778 dummy_int[1]=dir;
12159
12160
2/2
✓ Branch 0 taken 2907 times.
✓ Branch 1 taken 37871 times.
40778 if(clk3<2)
12161 {
12162 2907 y-=2; //up
12163 2907 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12164 2907 }
12165
2/2
✓ Branch 0 taken 4328 times.
✓ Branch 1 taken 33543 times.
37871 else if(clk3<5)
12166 {
12167 4328 y--; //up
12168 4328 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12169 4328 }
12170
2/2
✓ Branch 0 taken 4295 times.
✓ Branch 1 taken 29248 times.
33543 else if(clk3<8)
12171 {
12172 4295 dummy_int[2]=(dummy_int[1]==1)?right:left;
12173 4295 }
12174
2/2
✓ Branch 0 taken 4267 times.
✓ Branch 1 taken 24981 times.
29248 else if(clk3<11)
12175 {
12176 4267 y++; //down
12177 4267 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12178 4267 }
12179 else
12180 {
12181 24981 y+=2; //down
12182 24981 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12183 }
12184
12185 40778 ++clk3;
12186 40778 }
12187
2/2
✓ Branch 0 taken 1175 times.
✓ Branch 1 taken 175 times.
1350 else if(y<176)
12188 1175 clk3=0; // next bounce
12189 else
12190 175 clk2 = -(zc_oldrand()&63); // back to top
12191 42128 }
12192
12193 51400 return enemy::animate(index);
12194 51400 }
12195
12196 14169 void eRock::drawshadow(BITMAP *dest, bool translucent)
12197 {
12198
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 12347 times.
14169 if(clk2>=0)
12199 {
12200 12347 int32_t tempy=yofs;
12201 12347 flip = 0;
12202 12347 int32_t fdiv = frate/4;
12203
1/2
✓ Branch 0 taken 12347 times.
✗ Branch 1 not taken.
12347 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
12204
1/2
✓ Branch 0 taken 12347 times.
✗ Branch 1 not taken.
12347 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
12205 12347 efrate:((clk>=(frate>>1))?1:0);
12206 12347 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12207
12208 12347 yofs+=8;
12209
5/6
✓ Branch 0 taken 5808 times.
✓ Branch 1 taken 6539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12347 times.
✓ Branch 4 taken 5808 times.
✓ Branch 5 taken 6539 times.
12347 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12210
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12347 times.
12347 if(!shadow_overpit(this))
12211 12347 enemy::drawshadow(dest, translucent);
12212 12347 yofs=tempy;
12213 12347 }
12214 14169 }
12215
12216 51461 void eRock::draw(BITMAP *dest)
12217 {
12218
4/6
✓ Branch 0 taken 6877 times.
✓ Branch 1 taken 44584 times.
✓ Branch 2 taken 6877 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6877 times.
51461 if(clk2>=0 || fallclk||drownclk)
12219 {
12220 44584 int32_t tempdir=dir;
12221 44584 dir=dummy_int[2];
12222 44584 update_enemy_frame();
12223 44584 enemy::draw(dest);
12224 44584 dir=tempdir;
12225 44584 }
12226 51461 }
12227
12228 600 int32_t eRock::takehit(weapon*,weapon*)
12229 {
12230 600 return 0;
12231 }
12232
12233 60 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12234 60 {
12235 30 clk=0;
12236 30 mainguy=false;
12237 30 clk2=-14;
12238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12239 30 else hxofs= -10;
12240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12241 30 else hyofs=-10;
12242
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12243 30 else hxsz=36;
12244
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
12245 30 else hysz=36;
12246
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12247 30 else hzsz=16; //can't be jumped
12248
12249
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12250
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12251
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
12252
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
12253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12254 {
12255 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12256 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12257 }
12258
12259
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
12260 //nets+1680;
12261 30 }
12262
12263 4440 bool eBoulder::animate(int32_t index)
12264 {
12265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
12266
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
12267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
12268 return Dead(index);
12269
12270
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
12271 {
12272 290 removearmos(x,y,ffcactivated);
12273 290 }
12274
12275 zfix *vert;
12276
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_bit(quest_rules,qr_ENEMIESZAXIS) ? &z : &y;
12277
12278
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
12279 {
12280 32 x=zc_oldrand()&0xF0;
12281 32 y=-32;
12282 32 clk3=0;
12283 32 clk2=zc_oldrand()&15;
12284 32 }
12285
12286
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
12287 {
12288
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
12289 {
12290 131 dir=zc_oldrand()&1;
12291
12292
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
12293
12294
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
12295 131 }
12296
12297
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
12298 {
12299 3487 x += dir ? 1 : -1; //right, left
12300 3487 dummy_int[1]=dir;
12301
12302
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
12303 {
12304 261 y-=2; //up
12305 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12306 261 }
12307
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
12308 {
12309 382 y--; //up
12310 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
12311 382 }
12312
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
12313 {
12314 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
12315 376 }
12316
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
12317 {
12318 367 y++; //down
12319 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12320 367 }
12321 else
12322 {
12323 2101 y+=2; //down
12324 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
12325 }
12326
12327 3487 ++clk3;
12328 3487 }
12329
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
12330 101 clk3=0; // next bounce
12331 else
12332 10 clk2 = -(zc_oldrand()&63); // back to top
12333 3598 }
12334
12335 4440 return enemy::animate(index);
12336 4440 }
12337
12338 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
12339 {
12340
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
12341 {
12342 3868 int32_t tempy=yofs;
12343 3868 flip = 0;
12344 3868 int32_t f2=((clk<<2)/frate)<<1;
12345 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
12346
5/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3868 times.
✓ Branch 4 taken 1729 times.
✓ Branch 5 taken 2139 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
12347
12348 3868 yofs+=8;
12349 3868 xofs-=8;
12350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12351 3868 enemy::drawshadow(dest, translucent);
12352 3868 xofs+=16;
12353 3868 ++shadowtile;
12354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12355 3868 enemy::drawshadow(dest, translucent);
12356 3868 yofs+=16;
12357 3868 shadowtile+=20;
12358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12359 3868 enemy::drawshadow(dest, translucent);
12360 3868 xofs-=16;
12361 3868 --shadowtile;
12362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
12363 3868 enemy::drawshadow(dest, translucent);
12364 3868 xofs+=8;
12365 3868 yofs=tempy;
12366 3868 }
12367 4440 }
12368
12369 4440 void eBoulder::draw(BITMAP *dest)
12370 {
12371
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
12372 {
12373 3868 int32_t tempdir=dir;
12374 3868 dir=dummy_int[2];
12375 3868 update_enemy_frame();
12376 3868 dir=tempdir;
12377 3868 xofs-=8;
12378 3868 yofs-=8;
12379 3868 drawblock(dest,15);
12380 3868 xofs+=8;
12381 3868 yofs+=8;
12382 // enemy::draw(dest);
12383 3868 }
12384 4440 }
12385
12386 int32_t eBoulder::takehit(weapon*,weapon*)
12387 {
12388 return 0;
12389 }
12390
12391 4038 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
12392
3/4
✓ Branch 0 taken 2019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✓ Branch 3 taken 1505 times.
2019 minRange(get_bit(quest_rules, qr_BROKENSTATUES) ? 0 : Clk)
12393 4038 {
12394 /* fixing
12395 hp=1;
12396 */
12397 2019 mainguy=false;
12398
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2012 times.
2019 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12399 2019 hclk=clk; // the "no fire" range
12400 2019 clk=0;
12401 2019 clk3=96;
12402 2019 timer=0;
12403
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2012 times.
2019 if(o_tile==0)
12404 {
12405 2012 superman=1;
12406 2012 hxofs=1000;
12407 2012 }
12408 2019 SIZEflags = d->SIZEflags;
12409
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12410 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12411 // al_trace("Enemy txsz:%i\n", txsz);
12412
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12413
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12416
1/2
✓ Branch 0 taken 2019 times.
✗ Branch 1 not taken.
2019 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12417
1/2
✓ Branch 0 taken 2019 times.
✗ Branch 1 not taken.
2019 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12418 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12419
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
2019 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12421 {
12422 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12423 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12424 }
12425
12426
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2019 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2019 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12427 2019 }
12428
12429 1424319 bool eProjectile::animate(int32_t index)
12430 {
12431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1424319 times.
1424319 if(switch_hooked) return enemy::animate(index);
12432
2/4
✓ Branch 0 taken 1424319 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1424319 times.
1424319 if(fallclk||drownclk) return enemy::animate(index);
12433
2/2
✓ Branch 0 taken 1417470 times.
✓ Branch 1 taken 6849 times.
1424319 if(clk==0)
12434 {
12435 6849 removearmos(x,y,ffcactivated);
12436 6849 }
12437
12438 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12439 1424319 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12440
12441
4/4
✓ Branch 0 taken 471406 times.
✓ Branch 1 taken 952913 times.
✓ Branch 2 taken 257448 times.
✓ Branch 3 taken 213958 times.
1424319 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12442 {
12443 213958 dir=down;
12444 213958 }
12445
4/4
✓ Branch 0 taken 777159 times.
✓ Branch 1 taken 433202 times.
✓ Branch 2 taken 257448 times.
✓ Branch 3 taken 519711 times.
1210361 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12446 {
12447 519711 dir=right;
12448 519711 }
12449
4/4
✓ Branch 0 taken 482013 times.
✓ Branch 1 taken 208637 times.
✓ Branch 2 taken 257448 times.
✓ Branch 3 taken 224565 times.
690650 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
12450 {
12451 224565 dir=up;
12452 224565 }
12453 else
12454 {
12455 466085 dir=left;
12456 }
12457
12458
3/4
✓ Branch 0 taken 1424319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 741539 times.
✓ Branch 3 taken 682780 times.
1424319 if(!stunclk && ++clk3>80)
12459 {
12460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 682780 times.
682780 if(dmisc1==9) // Breath type
12461 {
12462 if(timer==0)
12463 {
12464 unsigned r=zc_oldrand();
12465
12466 if(!(r&63))
12467 {
12468 timer=zc_oldrand()%50+50;
12469 }
12470 }
12471
12472 if(timer>0)
12473 {
12474 if(timer%4==0)
12475 {
12476 FireBreath(false);
12477 }
12478
12479 if(--timer==0)
12480 {
12481 clk3=0;
12482 }
12483 }
12484 }
12485
12486 else // Not breath type
12487 {
12488 682780 unsigned r=zc_oldrand();
12489
12490
4/4
✓ Branch 0 taken 10626 times.
✓ Branch 1 taken 672154 times.
✓ Branch 2 taken 810 times.
✓ Branch 3 taken 9816 times.
682780 if(!(r&63) && !HeroInRange(minRange))
12491 {
12492 9816 FireWeapon();
12493
12494
3/4
✓ Branch 0 taken 7445 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
9868 if(get_bit(quest_rules, qr_BROKENSTATUES)==0 &&
12495
3/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 7393 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
7445 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
12496 {
12497
2/2
✓ Branch 0 taken 7023 times.
✓ Branch 1 taken 422 times.
7445 if(!((r>>7)&15))
12498 {
12499 422 x-=4;
12500 422 FireWeapon();
12501 422 x+=4;
12502 422 }
12503 7445 }
12504
12505 9816 clk3=0;
12506 9816 }
12507 }
12508 682780 }
12509
12510 1424319 return enemy::animate(index);
12511 1424319 }
12512
12513 1429636 void eProjectile::draw(BITMAP *dest)
12514 {
12515 1429636 update_enemy_frame();
12516 1429636 enemy::draw(dest);
12517 1429636 }
12518
12519 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12520 {
12521 hxofs=1000;
12522 }
12523
12524 void eTrigger::draw(BITMAP *dest)
12525 {
12526 update_enemy_frame();
12527 enemy::draw(dest);
12528 }
12529
12530 void eTrigger::death_sfx()
12531 {
12532 //silent death
12533 }
12534
12535 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12536 {
12537 o_tile+=wpnsbuf[iwNPCs].tile;
12538 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12539 SIZEflags = d->SIZEflags;
12540 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12541 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12542 // al_trace("Enemy txsz:%i\n", txsz);
12543 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12544 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12545 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12546 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12547 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12548 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12549 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12550 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12551 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12552 {
12553 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12554 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12555 }
12556
12557 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12558 }
12559
12560 bool eNPC::animate(int32_t index)
12561 {
12562 if(switch_hooked) return enemy::animate(index);
12563 if(dying)
12564 return Dead(index);
12565
12566 if(clk==0)
12567 {
12568 removearmos(x,y,ffcactivated);
12569 }
12570
12571 switch(dmisc2)
12572 {
12573 case 0:
12574 {
12575 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12576 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12577
12578 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
12579 {
12580 dir=down;
12581 }
12582
12583 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
12584 {
12585 dir=right;
12586 }
12587 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
12588 {
12589 dir=up;
12590 }
12591 else
12592 {
12593 dir=left;
12594 }
12595 }
12596 break;
12597
12598 case 1:
12599 halting_walk(rate, homing, 0, hrate, 48);
12600
12601 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
12602 {
12603 newdir(rate, homing, 0);
12604 clk2=48;
12605 ++misc;
12606 }
12607
12608 if(clk2==0)
12609 misc=0;
12610
12611 break;
12612 }
12613
12614 return enemy::animate(index);
12615 }
12616
12617 void eNPC::draw(BITMAP *dest)
12618 {
12619 update_enemy_frame();
12620 enemy::draw(dest);
12621 }
12622
12623 int32_t eNPC::takehit(weapon*,weapon*)
12624 {
12625 return 0;
12626 }
12627
12628 188 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12629 188 {
12630
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
12631 {
12632 94 o_tile=clk;
12633 94 cs=id>>12;
12634 94 }
12635
12636 94 id=id&0xFFF;
12637 94 clk=0;
12638
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
12639 94 mainguy=false;
12640 94 SIZEflags = d->SIZEflags;
12641
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12642 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12643 // al_trace("Enemy txsz:%i\n", txsz);
12644
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12646
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12648
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12649
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12650 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12651
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12653 {
12654 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12655 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12656 }
12657
12658
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12659 94 }
12660
12661 81 void eSpinTile::facehero()
12662 {
12663
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
12664 {
12665
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
12666 1 dir = up;
12667 else
12668 dir = down;
12669 1 }
12670 else
12671 {
12672 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12673 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12674
12675
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
12676 {
12677 12 dir=l_down;
12678 12 }
12679
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
12680 {
12681 1 dir=down;
12682 1 }
12683
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
12684 {
12685 12 dir=r_down;
12686 12 }
12687
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
12688 {
12689 6 dir=right;
12690 6 }
12691
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
12692 {
12693 17 dir=r_up;
12694 17 }
12695
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
12696 {
12697 8 dir=up;
12698 8 }
12699
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
12700 {
12701 6 dir=l_up;
12702 6 }
12703 else
12704 {
12705 18 dir=left;
12706 }
12707 }
12708 81 }
12709
12710
12711 15539 bool eSpinTile::animate(int32_t index)
12712 {
12713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
12714
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
12715
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
12716 {
12717 1152 return Dead(index);
12718 }
12719
12720
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
12721 {
12722 1241 removearmos(x,y,ffcactivated);
12723 1241 }
12724
12725 14387 ++misc;
12726
12727
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
12728 {
12729 81 facehero();
12730 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12731 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
12732 81 angular=true;
12733 81 angle=ddir;
12734 81 step=zslongToFix(dstep*100);
12735 81 }
12736
12737
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
12738 52 kickbucket();
12739
12740 14387 sprite::move(step);
12741 14387 return enemy::animate(index);
12742 15539 }
12743
12744 15457 void eSpinTile::draw(BITMAP *dest)
12745 {
12746 15457 update_enemy_frame();
12747 15457 y-=(misc>>4);
12748 15457 yofs+=2;
12749 15457 enemy::draw(dest);
12750 15457 yofs-=2;
12751 15457 y+=(misc>>4);
12752 15457 }
12753
12754 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
12755 {
12756 15457 flip = 0;
12757 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
12758 15457 yofs+=4;
12759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
12760 15457 enemy::drawshadow(dest, translucent);
12761 15457 yofs-=4;
12762 15457 }
12763
12764 2742 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
12765 2742 {
12766 //these are here to bypass compiler warnings about unused arguments
12767 1371 Clk=Clk;
12768 1371 mainguy=false;
12769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
1371 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12770 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
12771 {
12772 clk=1;
12773 }*/
12774 //nets+880;
12775 1371 SIZEflags = d->SIZEflags;
12776
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12777 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12778 // al_trace("Enemy txsz:%i\n", txsz);
12779
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12780
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12781
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12782
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12783
1/2
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
1371 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12784
1/2
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
1371 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12785 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12786
1/4
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
1371 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12788 {
12789 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12790 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12791 }
12792
12793
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1371 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1371 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12794 1371 }
12795
12796 370007 void eZora::facehero()
12797 {
12798
2/2
✓ Branch 0 taken 6197 times.
✓ Branch 1 taken 363810 times.
370007 if(Hero.x-x==0)
12799 {
12800 6197 dir=(Hero.y+8<y)?up:down;
12801 6197 }
12802 else
12803 {
12804 double _MSVC2022_tmp1, _MSVC2022_tmp2;
12805 363810 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
12806
12807
4/4
✓ Branch 0 taken 76040 times.
✓ Branch 1 taken 287770 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 47323 times.
363810 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
12808 {
12809 47323 dir=l_down;
12810 47323 }
12811
4/4
✓ Branch 0 taken 54130 times.
✓ Branch 1 taken 262357 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 25413 times.
316487 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
12812 {
12813 25413 dir=down;
12814 25413 }
12815
4/4
✓ Branch 0 taken 73430 times.
✓ Branch 1 taken 217644 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 44713 times.
291074 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
12816 {
12817 44713 dir=r_down;
12818 44713 }
12819
4/4
✓ Branch 0 taken 98067 times.
✓ Branch 1 taken 148294 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 69350 times.
246361 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
12820 {
12821 69350 dir=right;
12822 69350 }
12823
4/4
✓ Branch 0 taken 78233 times.
✓ Branch 1 taken 98778 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 49516 times.
177011 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
12824 {
12825 49516 dir=r_up;
12826 49516 }
12827
4/4
✓ Branch 0 taken 51593 times.
✓ Branch 1 taken 75902 times.
✓ Branch 2 taken 28717 times.
✓ Branch 3 taken 22876 times.
127495 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
12828 {
12829 22876 dir=up;
12830 22876 }
12831
4/4
✓ Branch 0 taken 71275 times.
✓ Branch 1 taken 33344 times.
✓ Branch 2 taken 42558 times.
✓ Branch 3 taken 28717 times.
104619 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
12832 {
12833 42558 dir=l_up;
12834 42558 }
12835 else
12836 {
12837 62061 dir=left;
12838 }
12839 }
12840 370007 }
12841
12842 487876 bool eZora::animate(int32_t index)
12843 {
12844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 487876 times.
487876 if(switch_hooked) return enemy::animate(index);
12845
2/2
✓ Branch 0 taken 1836 times.
✓ Branch 1 taken 486040 times.
487876 if(dying)
12846 1836 return Dead(index);
12847
12848
2/2
✓ Branch 0 taken 482891 times.
✓ Branch 1 taken 3149 times.
486040 if(clk==0)
12849 {
12850 3149 removearmos(x,y,ffcactivated);
12851 3149 }
12852
12853
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 486009 times.
486040 if(watch)
12854 {
12855 31 ++clock_zoras[id];
12856 31 return true;
12857 }
12858
12859
2/2
✓ Branch 0 taken 116002 times.
✓ Branch 1 taken 370007 times.
486009 if(get_bit(quest_rules,qr_NEWENEMYTILES))
12860 {
12861 370007 facehero();
12862 370007 }
12863
12864
6/6
✓ Branch 0 taken 2922 times.
✓ Branch 1 taken 2816 times.
✓ Branch 2 taken 2359 times.
✓ Branch 3 taken 472362 times.
✓ Branch 4 taken 3763 times.
✓ Branch 5 taken 1787 times.
486009 switch(clk)
12865 {
12866 case 0: // reposition him
12867 {
12868 3763 int32_t t=0;
12869 3763 int32_t pos2=zc_oldrand()%160 + 16;
12870 3763 bool placed=false;
12871
12872
4/4
✓ Branch 0 taken 3740 times.
✓ Branch 1 taken 18779 times.
✓ Branch 2 taken 11890 times.
✓ Branch 3 taken 3149 times.
22519 while(!placed && t<160)
12873 {
12874 11890 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
12875
5/6
✓ Branch 0 taken 3828 times.
✓ Branch 1 taken 8062 times.
✓ Branch 2 taken 3828 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 307 times.
✓ Branch 5 taken 3126 times.
15323 if(watertype && ((editorflags & ENEMY_FLAG6) ||
12876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3828 times.
3828 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
12877
3/4
✓ Branch 0 taken 3828 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3433 times.
✓ Branch 3 taken 3433 times.
3828 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
12878 {
12879 3126 x=(pos2&15)<<4;
12880 3126 y=pos2&0xF0;
12881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3126 times.
3126 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
12882 3126 hxofs=1000; // avoid hit detection
12883 3126 stunclk=0;
12884 3126 placed=true;
12885 3126 }
12886
12887 18756 pos2+=19;
12888
12889
2/2
✓ Branch 0 taken 16549 times.
✓ Branch 1 taken 2207 times.
18756 if(pos2>=176)
12890 2207 pos2-=160;
12891
12892 18756 ++t;
12893 }
12894
12895
3/4
✓ Branch 0 taken 3126 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3126 times.
3149 if(!placed || whistleclk>=88) // can't place him, he's gone
12896 23 return true;
12897
12898 }
12899 3126 break;
12900
12901 case 35:
12902
2/2
✓ Branch 0 taken 2232 times.
✓ Branch 1 taken 690 times.
2922 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
12903 {
12904 690 dir=(Hero.y+8<y)?up:down;
12905 690 }
12906
12907 2922 hxofs=0;
12908 2922 break;
12909
12910 case 35+19:
12911 2816 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
12912 2816 sfx(wpnsfx(wpn),pan(int32_t(x)));
12913 2816 break;
12914
12915 case 35+66:
12916 2359 hxofs=1000;
12917 2359 break;
12918
12919 case 198:
12920 1787 clk=-1;
12921 1787 break;
12922 }
12923
12924 485372 return enemy::animate(index);
12925 487262 }
12926
12927 487649 void eZora::draw(BITMAP *dest)
12928 {
12929
2/2
✓ Branch 0 taken 9385 times.
✓ Branch 1 taken 478264 times.
487649 if(clk<3)
12930 9385 return;
12931
12932 478264 update_enemy_frame();
12933 478264 enemy::draw(dest);
12934 487649 }
12935
12936 bool eZora::isSubmerged() const
12937 {
12938 return ( clk < 3 );
12939 }
12940
12941
4/8
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16957 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16957 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16957 times.
✗ Branch 7 not taken.
50871 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12942 33914 {
12943 16957 multishot= timer = fired = dashing = 0;
12944 16957 hashero = false;
12945 16957 dummy_bool[0]=false;
12946 16957 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
12947
5/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 16840 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 50 times.
16957 if(dmisc9==e9tARMOS && zc_oldrand()&1)
12948 {
12949
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
67 step=zslongToFix(dmisc10*100);
12950
12951
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 60 times.
67 if(anim==aARMOS4) o_tile+=20;
12952 67 }
12953
12954
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 16840 times.
16957 if(flags & guy_fadeflicker)
12955 {
12956 117 clk=0;
12957 117 superman = 1;
12958 117 fading=fade_flicker;
12959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
12960 117 dir=down;
12961
12962
4/6
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 65 times.
117 if(!canmove(down,(zfix)8,spw_none,false))
12963
3/6
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
52 clk3=int32_t(13.0/step);
12964 117 }
12965
1/2
✓ Branch 0 taken 16840 times.
✗ Branch 1 not taken.
16840 else if(flags & guy_fadeinstant)
12966 {
12967 clk=0;
12968 }
12969
12970
1/2
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
16957 shadowdistance = 0;
12971 16957 clk4 = clk5 = 0;
12972 //nets+2380;
12973 16957 SIZEflags = d->SIZEflags;
12974
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12975 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12976 // al_trace("Enemy txsz:%i\n", txsz);
12977
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12978
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
12979
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
12980
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12981
1/2
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
16957 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12982
1/2
✓ Branch 0 taken 16957 times.
✗ Branch 1 not taken.
16957 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12983 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12984
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
16957 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12986 {
12987 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12988 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12989 }
12990
12991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16957 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16957 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12992 16957 }
12993
12994 7027045 bool eStalfos::animate(int32_t index)
12995 {
12996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7027045 times.
7027045 if(switch_hooked) return enemy::animate(index);
12997
3/4
✓ Branch 0 taken 7026903 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7026903 times.
7027045 if(fallclk||drownclk)
12998 {
12999 142 return enemy::animate(index);
13000 }
13001
2/2
✓ Branch 0 taken 156550 times.
✓ Branch 1 taken 6870353 times.
7026903 if(dying)
13002 {
13003
2/2
✓ Branch 0 taken 156522 times.
✓ Branch 1 taken 28 times.
156550 if(hashero)
13004 {
13005 28 Hero.setEaten(0);
13006 28 hashero=false;
13007 28 }
13008
13009
10/14
✓ Branch 0 taken 14564 times.
✓ Branch 1 taken 141986 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 13424 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
156550 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
13010 {
13011 49 hp=-1000;
13012
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
13013 49 Ewpns.add(ew);
13014 49 ew->fakez = fakez;
13015
13016
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
13017 {
13018 49 ew->step=0;
13019 49 ew->id=wpn;
13020 49 ew->misc=50;
13021 49 ew->clk=48;
13022 49 }
13023
13024 49 fired=true;
13025 49 }
13026
6/6
✓ Branch 0 taken 74530 times.
✓ Branch 1 taken 81971 times.
✓ Branch 2 taken 61392 times.
✓ Branch 3 taken 13138 times.
✓ Branch 4 taken 61374 times.
✓ Branch 5 taken 18 times.
156501 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
13027 {
13028
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
13029 {
13030 1 int32_t wpn2 = wpn+dmisc3;
13031
13032
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
13033 {
13034 wpn2=wpn;
13035 }
13036
13037 1 dummy_bool[0]=true;
13038 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
13039 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13040 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
13041 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13042 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
13043 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13044 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
13045 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13046 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
13047 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13048 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
13049 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13050 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
13051 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13052 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
13053 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
13054 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
13055 1 }
13056 18 }
13057
13058 156550 KillWeapon();
13059 156550 return Dead(index);
13060 }
13061 //vire split
13062 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
13063 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
13064
13/14
✓ Branch 0 taken 8833 times.
✓ Branch 1 taken 6861520 times.
✓ Branch 2 taken 8833 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 8684 times.
✓ Branch 6 taken 660353 times.
✓ Branch 7 taken 6209851 times.
✓ Branch 8 taken 659185 times.
✓ Branch 9 taken 1168 times.
✓ Branch 10 taken 3212 times.
✓ Branch 11 taken 655973 times.
✓ Branch 12 taken 591 times.
✓ Branch 13 taken 2621 times.
6870353 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
13065 {
13066 740 stop_bgsfx(index);
13067 740 int32_t kids = guys.Count();
13068 740 int32_t id2=dmisc3;
13069
2/2
✓ Branch 0 taken 1466 times.
✓ Branch 1 taken 740 times.
2206 for(int32_t i=0; i < dmisc4; i++)
13070 {
13071 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13072
4/6
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 1124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1124 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1466 times.
1466 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
13073 1466 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13074 1466 }
13075
13076
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(itemguy) // Hand down the carried item
13077 {
13078 guycarryingitem = guys.Count()-1;
13079 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13080 itemguy = false;
13081 }
13082
13083
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if(hashero)
13084 {
13085 Hero.setEaten(0);
13086 hashero=false;
13087 }
13088
13089
4/4
✓ Branch 0 taken 726 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 591 times.
✓ Branch 3 taken 135 times.
740 if(deadsfx > 0 && dmisc2==e2tSPLIT)
13090 135 sfx(deadsfx,pan(int32_t(x)));
13091
13092 740 return true;
13093 }
13094 /*
13095 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
13096 {
13097 stop_bgsfx(index);
13098 int32_t kids = guys.Count();
13099 int32_t id2=dmisc3;
13100
13101 for(int32_t i=0; i < dmisc4; i++)
13102 {
13103 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
13104 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
13105 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13106 }
13107
13108 if(itemguy) // Hand down the carried item
13109 {
13110 guycarryingitem = guys.Count()-1;
13111 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13112 itemguy = false;
13113 }
13114
13115 if(hashero)
13116 {
13117 Hero.setEaten(0);
13118 hashero=false;
13119 }
13120
13121 return true;
13122 }
13123 */
13124
2/2
✓ Branch 0 taken 7805 times.
✓ Branch 1 taken 6861808 times.
6869613 if(fading)
13125 {
13126
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 7661 times.
7805 if(++clk4 > 60)
13127 {
13128 144 clk4=0;
13129 144 superman=0;
13130 144 fading=0;
13131
13132
4/6
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 117 times.
144 if(flags2&cmbflag_armos && z==0 && fakez == 0)
13133 {
13134 //if a custom size (not 16px by 16px)
13135
13136 //if a custom size (not 16px by 16px)
13137
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if (ffcactivated)
13138 removearmosffc(ffcactivated-1);
13139 else
13140 {
13141
4/8
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 117 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 117 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 117 times.
117 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13142 {
13143 //zprint("spawn big enemy from armos\n");
13144 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13145 for(int32_t dx = 0; dx < tysz; dx ++)
13146 {
13147 for(int32_t dy = 0; dy < tysz; dy++)
13148 {
13149 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
13150 did_armos = false;
13151 }
13152 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
13153 did_armos = false;
13154 }
13155 for(int32_t dy = 0; dy < tysz; dy ++)
13156 {
13157 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
13158 did_armos = false;
13159 }
13160 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
13161 }
13162 117 else removearmos(x,y);
13163 }
13164 /*
13165 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
13166 {
13167 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
13168 for(int32_t dx = 0; dx < hxsz; dx += 16)
13169 {
13170 for(int32_t dy = 0; dy < hysz; dy += 16)
13171 {
13172 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
13173 did_armos = false;
13174 }
13175 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13176 did_armos = false;
13177 }
13178 for(int32_t dy = 0; dy < hysz; dy += 16)
13179 {
13180 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
13181 did_armos = false;
13182 }
13183 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
13184 }
13185 else removearmos(x,y,ffcactivated);
13186 */
13187
13188 117 }
13189
13190 144 clk2=0;
13191
13192 144 newdir();
13193 144 }
13194 7661 else return enemy::animate(index);
13195 144 }
13196
6/8
✓ Branch 0 taken 29439 times.
✓ Branch 1 taken 6832369 times.
✓ Branch 2 taken 29439 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29439 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27572 times.
✓ Branch 7 taken 1867 times.
6861808 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
13197 1867 removearmos(x,y,ffcactivated);
13198
13199
13200
2/2
✓ Branch 0 taken 2221 times.
✓ Branch 1 taken 6859731 times.
6861952 if(hashero)
13201 {
13202 2221 Hero.setX(x);
13203 2221 Hero.setY(y);
13204 2221 ++clk2;
13205
13206
4/4
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2171 times.
✓ Branch 3 taken 50 times.
2221 if(clk2==(dmisc8==0 ? 95 : dmisc8))
13207 {
13208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 switch(dmisc7)
13209 {
13210 case e7tEATITEMS:
13211 {
13212 for(int32_t i=0; i<MAXITEMS; i++)
13213 {
13214 if(itemsbuf[i].flags&ITEM_EDIBLE)
13215 game->set_item(i, false);
13216 }
13217
13218 break;
13219 }
13220
13221 case e7tEATMAGIC:
13222 game->change_dmagic(-1*game->get_magicdrainrate());
13223 break;
13224
13225 case e7tEATRUPEES:
13226 game->change_drupy(-1);
13227 break;
13228 }
13229
13230 50 clk2=0;
13231 50 }
13232
13233
2/2
✓ Branch 0 taken 169 times.
✓ Branch 1 taken 2052 times.
2221 if((clk&0x18)==8) // stop its animation on the middle frame
13234 2052 --clk;
13235 2221 }
13236
4/4
✓ Branch 0 taken 438916 times.
✓ Branch 1 taken 6420815 times.
✓ Branch 2 taken 251749 times.
✓ Branch 3 taken 187167 times.
6859731 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
13237 {
13238 // Movement engine
13239
4/6
✓ Branch 0 taken 331274 times.
✓ Branch 1 taken 6341290 times.
✓ Branch 2 taken 2047 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6339243 times.
✗ Branch 5 not taken.
6672564 if(clk>=0) switch(id>>12)
13240 {
13241 case 0: // Normal movement
13242
13243 /*
13244 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
13245 {
13246 // Overloading clk4 (Tribble clock) here...
13247 step=17/100.0;
13248 if(clk4<32) misc=1;
13249 else if(clk4<48) misc=2;
13250 else if(clk4<300) { misc=3; step = dstep/100.0; }
13251 else if(clk4<316) misc=2;
13252 else if(clk4<412) misc=1;
13253 else if(clk4<540) { misc=0; step=0; }
13254 else clk4=0;
13255 if(clk4==48) clk=0;
13256 hxofs=(misc>=2)?0:1000;
13257 if (dmisc9==e9tLEEVER)
13258 variable_walk(rate, homing, 0);
13259 else
13260 variable_walk_8(rate, homing, 4, 0);
13261 break;
13262 }
13263 */
13264
4/4
✓ Branch 0 taken 6199224 times.
✓ Branch 1 taken 140019 times.
✓ Branch 2 taken 216564 times.
✓ Branch 3 taken 5982660 times.
6339243 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
13265 {
13266 356583 vire_hop();
13267 356583 break;
13268 }
13269
2/2
✓ Branch 0 taken 454101 times.
✓ Branch 1 taken 5528559 times.
5982660 else if(dmisc9==e9tROPE) //Rope charge
13270 {
13271
9/10
✓ Branch 0 taken 436679 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 67093 times.
✓ Branch 3 taken 369586 times.
✓ Branch 4 taken 61231 times.
✓ Branch 5 taken 5862 times.
✓ Branch 6 taken 60515 times.
✓ Branch 7 taken 716 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 60515 times.
454101 if(!fired && dashing && !stunclk && !watch && !frozenclock)
13272 {
13273
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 58143 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
60515 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
13274 {
13275
13276
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_bit(quest_rules,qr_BOMBCHUSUPERBOMB) )
13277 {
13278 14 hp=-1000;
13279
13280
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13281 {
13282
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
13283 14 Ewpns.add(ew);
13284 14 ew->fakez = fakez;
13285
13286
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
13287 {
13288 14 ew->step=0;
13289 14 ew->id=wpn+dmisc3;
13290 14 ew->misc=50;
13291 14 ew->clk=48;
13292 14 }
13293
13294 14 fired=true;
13295 14 }
13296 else
13297 {
13298 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
13299 Ewpns.add(ew);
13300 ew->fakez = fakez;
13301
13302 if(wpn==ewSBomb || wpn==ewBomb)
13303 {
13304 ew->step=0;
13305 ew->id=wpn;
13306 ew->misc=50;
13307 ew->clk=48;
13308 }
13309
13310 fired=true;
13311 }
13312 14 }
13313
13314 else
13315 {
13316 1 hp=-1000;
13317
13318 int32_t wpn2;
13319
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
13320 1 wpn2=wpn;
13321 else
13322 wpn2=wpn;
13323
13324
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
13325 1 Ewpns.add(ew);
13326 1 ew->fakez = fakez;
13327
13328
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
13329 {
13330 1 ew->step=0;
13331 1 ew->id=wpn2;
13332 1 ew->misc=50;
13333 1 ew->clk=48;
13334 1 }
13335
13336 1 fired=true;
13337 }
13338 15 }
13339 60515 }
13340
13341 454101 charge_attack();
13342 454101 break;
13343 }
13344 /*
13345 * Boomerang-throwers have a halt count of 1
13346 * Zols have a halt count of (zc_oldrand()&7)<<4
13347 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
13348 * Everything else has 48
13349 */
13350 else
13351 {
13352
2/2
✓ Branch 0 taken 236388 times.
✓ Branch 1 taken 5292171 times.
5528559 if(wpn==ewBrang) // Goriya
13353 {
13354 236388 halting_walk(rate,homing,0,hrate, 1);
13355 236388 }
13356
4/4
✓ Branch 0 taken 5262615 times.
✓ Branch 1 taken 29556 times.
✓ Branch 2 taken 1900845 times.
✓ Branch 3 taken 3361770 times.
5292171 else if(dmisc9==e9tNORMAL && wpn==0)
13357 {
13358
2/2
✓ Branch 0 taken 485805 times.
✓ Branch 1 taken 2875965 times.
3361770 if(dmisc2==e2tSPLITHIT) // Zol
13359 {
13360 485805 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
13361 485805 }
13362
4/4
✓ Branch 0 taken 965978 times.
✓ Branch 1 taken 1909987 times.
✓ Branch 2 taken 900443 times.
✓ Branch 3 taken 65535 times.
2875965 else if(frate<=8 && starting_hp==1) // Gel
13363 {
13364 65535 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
13365 65535 }
13366 else // Other
13367 {
13368 2810430 halting_walk(rate,homing,0,hrate, 48);
13369 }
13370 3361770 }
13371 else // Other
13372 {
13373 1930401 halting_walk(rate,homing,0,hrate, 48);
13374 }
13375 }
13376
13377 //if not in midair, and Hero's swinging sword is nearby, jump.
13378 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
13379 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
13380 {
13381 facehero(false);
13382 sclk=16+((dir^1)<<8);
13383 fall=-FEATHERJUMP;
13384 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
13385 }*/
13386 5528559 break;
13387
13388 // Following cases are for just after creation-by-splitting.
13389 case 1:
13390
2/2
✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 508 times.
2047 if(misc==1)
13391 {
13392 508 dir=up;
13393 508 step=8;
13394 508 }
13395
13396
2/2
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 1556 times.
2047 if(misc<=2)
13397 {
13398 1556 move(step);
13399
13400
2/2
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 287 times.
1556 if(!canmove(dir,(zfix)0,0,false))
13401 287 dir=down;
13402 1556 }
13403
13404
2/2
✓ Branch 0 taken 1556 times.
✓ Branch 1 taken 491 times.
2047 if(misc==3)
13405 {
13406
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 312 times.
491 if(canmove(right,(zfix)16,0,false))
13407 312 x+=16;
13408 491 }
13409
13410 2047 ++misc;
13411 2047 break;
13412
13413 case 2:
13414 if(misc==1)
13415 {
13416 dir=down;
13417 step=8;
13418 }
13419
13420 if(misc<=2)
13421 {
13422 move(step);
13423 /*
13424 if(!canmove(dir,(zfix)0,0,false))
13425 dir=up;
13426 */
13427 }
13428
13429 if(misc==3)
13430 {
13431 if(canmove(left,(zfix)16,0,false))
13432 x-=16;
13433 }
13434
13435 ++misc;
13436 break;
13437
13438 default:
13439 if(misc==1)
13440 {
13441 dir=(zc_oldrand()%4);
13442 step=8;
13443 }
13444
13445 if(misc<=2)
13446 {
13447 move(step);
13448
13449 if(!canmove(dir,(zfix)0,0,false))
13450 dir=dir^1;
13451 }
13452
13453 if(misc==3)
13454 {
13455 if(dir >= left && canmove(dir,(zfix)16,0,false))
13456 x+=(dir==left ? -16 : 16);
13457 }
13458
13459 ++misc;
13460 break;
13461 6341290 }
13462
13463
4/4
✓ Branch 0 taken 14221 times.
✓ Branch 1 taken 6658343 times.
✓ Branch 2 taken 13730 times.
✓ Branch 3 taken 491 times.
6672564 if(id>>12 && misc>=4) //recently spawned by a split enemy
13464 {
13465 491 id&=0xFFF;
13466 491 step = zslongToFix(dstep*100);
13467
13468
1/2
✓ Branch 0 taken 491 times.
✗ Branch 1 not taken.
491 if(x<32) x=32;
13469
13470
2/2
✓ Branch 0 taken 483 times.
✓ Branch 1 taken 8 times.
491 if(x>208) x=208;
13471
13472
2/2
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 13 times.
491 if(y<32) y=32;
13473
13474
2/2
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 5 times.
491 if(y>128) y=128;
13475
13476 491 misc=3;
13477 491 }
13478 6672564 }
13479 else
13480 {
13481 //sfx(wpnsfx(wpn),pan(int32_t(x)));
13482
1/2
✓ Branch 0 taken 187167 times.
✗ Branch 1 not taken.
187167 if(clk2>2) clk2--;
13483 }
13484
13485 // Fire Zol
13486
7/8
✓ Branch 0 taken 2581202 times.
✓ Branch 1 taken 4280750 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 2574568 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 47 times.
6861952 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
13487 {
13488 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
13489 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
13490
13491 47 int32_t i=Ewpns.Count()-1;
13492 47 weapon *ew = (weapon*)(Ewpns.spr(i));
13493
13494
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
13495 {
13496 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
13497 if ( ew->do_animation ) ew->tile+=ew->aframe;
13498 }
13499 47 }
13500 // Goriya
13501
14/16
✓ Branch 0 taken 438916 times.
✓ Branch 1 taken 6422989 times.
✓ Branch 2 taken 205580 times.
✓ Branch 3 taken 233336 times.
✓ Branch 4 taken 199606 times.
✓ Branch 5 taken 5974 times.
✓ Branch 6 taken 182448 times.
✓ Branch 7 taken 17158 times.
✓ Branch 8 taken 182448 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 180226 times.
✓ Branch 11 taken 2222 times.
✓ Branch 12 taken 180226 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 177570 times.
✓ Branch 15 taken 2656 times.
6861905 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
13502 {
13503 2656 misc=index+100;
13504
7/14
✓ Branch 0 taken 2656 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2656 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2656 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2656 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2656 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2656 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2656 times.
✗ Branch 13 not taken.
2656 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
13505 2656 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
13506
13507
2/2
✓ Branch 0 taken 2501 times.
✓ Branch 1 taken 155 times.
2656 if(dmisc1==2)
13508 {
13509 155 int32_t ndir=dir;
13510
13511
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
13512 {
13513 4 ndir=(Hero.y+8<y)?up:down;
13514 4 }
13515 else //turn to face Hero
13516 {
13517 double _MSVC2022_tmp1, _MSVC2022_tmp2;
13518 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
13519
13520
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
13521 {
13522 9 ndir=down;
13523 9 }
13524
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
13525 {
13526 41 ndir=right;
13527 41 }
13528
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
13529 {
13530 33 ndir=up;
13531 33 }
13532 else
13533 {
13534 68 ndir=left;
13535 }
13536 }
13537
13538 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
13539
13540
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
13541 {
13542 153 dir=ndir;
13543 153 }
13544 155 }
13545 2656 }
13546
15/16
✓ Branch 0 taken 6831913 times.
✓ Branch 1 taken 27336 times.
✓ Branch 2 taken 102427 times.
✓ Branch 3 taken 6756822 times.
✓ Branch 4 taken 90516 times.
✓ Branch 5 taken 11911 times.
✓ Branch 6 taken 75809 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 75210 times.
✓ Branch 9 taken 599 times.
✓ Branch 10 taken 70403 times.
✓ Branch 11 taken 4807 times.
✓ Branch 12 taken 70403 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 69459 times.
6859249 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
13547
3/3
✓ Branch 0 taken 10948 times.
✓ Branch 1 taken 57610 times.
✓ Branch 2 taken 901 times.
69459 switch(dmisc1)
13548 {
13549 case e1tCONSTANT: //Deathnut
13550 {
13551 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
13552
2/2
✓ Branch 0 taken 56404 times.
✓ Branch 1 taken 1206 times.
57610 if(clk5>64)
13553 {
13554 1206 clk5=0;
13555 1206 fired=false;
13556 1206 }
13557
13558 57610 clk5+=(zc_oldrand()&3);
13559
13560
4/4
✓ Branch 0 taken 35436 times.
✓ Branch 1 taken 22174 times.
✓ Branch 2 taken 12000 times.
✓ Branch 3 taken 23436 times.
57610 if((clk5>24)&&(clk5<52))
13561 {
13562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23436 times.
23436 if ( do_animation )tile+=20; //firing
13563
13564
4/4
✓ Branch 0 taken 12824 times.
✓ Branch 1 taken 10612 times.
✓ Branch 2 taken 11525 times.
✓ Branch 3 taken 1299 times.
23436 if(!fired&&(clk5>=38))
13565 {
13566
5/10
✓ Branch 0 taken 1299 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1299 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1299 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1299 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1299 times.
✗ Branch 9 not taken.
1299 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
13567 1299 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
13568 1299 sfx(wpnsfx(wpn),pan(int32_t(x)));
13569 1299 fired=true;
13570 1299 }
13571 23436 }
13572
13573 57610 break;
13574 }
13575
13576 case e1tFIREOCTO: //Fire Octo
13577 901 timer=zc_oldrand()%50+50;
13578 901 break;
13579
13580 default:
13581 10948 FireWeapon();
13582 10948 break;
13583 69459 }
13584
13585 /* Fire again if:
13586 * - clk2 about to run out
13587 * - not already double-firing (dmisc1 is 1)
13588 * - not carrying Hero
13589 * - one in 0xF chance
13590 */
13591
8/10
✓ Branch 0 taken 231061 times.
✓ Branch 1 taken 6630891 times.
✓ Branch 2 taken 2272 times.
✓ Branch 3 taken 228789 times.
✓ Branch 4 taken 2272 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2272 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 153 times.
✓ Branch 9 taken 2119 times.
6861952 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
13592 {
13593 #if 1
13594 153 newdir(rate, homing, grumble);
13595 #else
13596 dir^=2;
13597 #endif
13598 153 clk2=28;
13599 153 ++multishot;
13600 153 }
13601
13602
2/2
✓ Branch 0 taken 1684557 times.
✓ Branch 1 taken 5177395 times.
6861952 if(clk2==0)
13603 {
13604 5177395 multishot = 0;
13605 5177395 }
13606
13607
2/2
✓ Branch 0 taken 6797835 times.
✓ Branch 1 taken 64117 times.
6861952 if(timer) //Fire Octo
13608 {
13609 64117 clk2=15; //this keeps the octo in place until he's done firing
13610
13611
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
13612 {
13613 15704 FireBreath(false);
13614 15704 }
13615
13616 64117 --timer;
13617 64117 }
13618
13619
2/2
✓ Branch 0 taken 6696965 times.
✓ Branch 1 taken 164987 times.
6861952 if(dmisc2==e2tTRIBBLE)
13620 164987 ++clk4;
13621
13622
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 6859712 times.
✓ Branch 2 taken 588 times.
✓ Branch 3 taken 6861364 times.
✓ Branch 4 taken 588 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 588 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 588 times.
6861952 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
13623 {
13624 588 int32_t kids = guys.Count();
13625 588 int32_t id2=dmisc3;
13626
13627
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 588 times.
1176 for(int32_t i=0; i<dmisc4; i++)
13628 {
13629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 588 times.
588 if(addenemy(x,y,id2,-24))
13630 {
13631
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(itemguy) // Hand down the carried item
13632 {
13633 guycarryingitem = guys.Count()-1;
13634 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13635 itemguy = false;
13636 }
13637
13638 588 ((enemy*)guys.spr(kids+i))->count_enemy = false;
13639 588 }
13640 588 }
13641
13642
1/2
✓ Branch 0 taken 588 times.
✗ Branch 1 not taken.
588 if(hashero)
13643 {
13644 Hero.setEaten(0);
13645 hashero=false;
13646 }
13647
13648 588 stop_bgsfx(index);
13649 588 return true;
13650 }
13651
13652 6861364 return enemy::animate(index);
13653 7027045 }
13654
13655 7332153 void eStalfos::draw(BITMAP *dest)
13656 {
13657 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
13658 {
13659 clk4--; //Kludge
13660 return;
13661 }*/
13662
13663 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
13664 {
13665 cs = dcset;
13666 }*/
13667 7332153 update_enemy_frame();
13668
13669
7/8
✓ Branch 0 taken 7332011 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 7332011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 7296036 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
7332153 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
13670 {
13671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
13672 2890 }
13673
13674 7332153 enemy::draw(dest);
13675 7332153 }
13676
13677 1816775 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
13678 {
13679 1816775 int32_t tempy=yofs;
13680
13681 /*
13682 if (clk6 && dir>=left && !get_bit(quest_rules,qr_ENEMIESZAXIS)) {
13683 flip = 0;
13684 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13685 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
13686 shadowtile = wpnsbuf[spr_shadow].tile+f2;
13687 yofs+=(((int32_t)y+17)&0xF0)-y;
13688 yofs+=8;
13689 }
13690 */
13691
3/4
✓ Branch 0 taken 1736002 times.
✓ Branch 1 taken 80773 times.
✓ Branch 2 taken 1816775 times.
✗ Branch 3 not taken.
1816775 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_ENEMIESZAXIS))
13692 {
13693 flip = 0;
13694 int32_t fdiv = frate/4;
13695 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13696
13697 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13698 efrate:((clk>=(frate>>1))?1:0);
13699 shadowtile = wpnsbuf[spr_shadow].tile;
13700
13701 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13702 {
13703 shadowtile+=f2;
13704 }
13705 else
13706 {
13707 shadowtile+=f2?1:0;
13708 }
13709
13710 yofs+=shadowdistance;
13711 yofs+=8;
13712 }
13713
3/4
✓ Branch 0 taken 1736002 times.
✓ Branch 1 taken 80773 times.
✓ Branch 2 taken 1816775 times.
✗ Branch 3 not taken.
1816775 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_bit(quest_rules,qr_POLVIRE_NO_SHADOW))
13714 {
13715 flip = 0;
13716 int32_t fdiv = frate/4;
13717 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13718
13719 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
13720 efrate:((clk>=(frate>>1))?1:0);
13721 shadowtile = wpnsbuf[spr_shadow].tile;
13722
13723 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13724 {
13725 shadowtile+=f2;
13726 }
13727 else
13728 {
13729 shadowtile+=f2?1:0;
13730 }
13731 }
13732
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1816633 times.
1816775 if(!shadow_overpit(this))
13733 1816633 enemy::drawshadow(dest, translucent);
13734 1816775 yofs=tempy;
13735 1816775 }
13736
13737 78749 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
13738 {
13739 78749 int32_t wpnId = w->id;
13740 78749 int32_t wpnDir = w->dir;
13741
13742
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 78642 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 72 times.
78749 if(wpnId==wHammer && shield && (flags & guy_bkshield)
13743
5/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
35 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
13744
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
13745 {
13746 23 shield = false;
13747 23 flags &= ~(inv_left|inv_right|inv_back|inv_front);
13748
13749
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
13750 1 o_tile=s_tile;
13751 23 }
13752
13753 78749 int32_t ret = enemy::takehit(w,realweap);
13754
13755
4/4
✓ Branch 0 taken 9022 times.
✓ Branch 1 taken 69727 times.
✓ Branch 2 taken 7954 times.
✓ Branch 3 taken 1068 times.
78749 if(sclk && dmisc2==e2tSPLITHIT)
13756 1068 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
13757
13758 78749 return ret;
13759 }
13760
13761 454101 void eStalfos::charge_attack()
13762 {
13763
2/2
✓ Branch 0 taken 4498 times.
✓ Branch 1 taken 449603 times.
454101 if(slide())
13764 4498 return;
13765
13766
9/12
✓ Branch 0 taken 449603 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 449603 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 436092 times.
✓ Branch 5 taken 13511 times.
✓ Branch 6 taken 420323 times.
✓ Branch 7 taken 15769 times.
✓ Branch 8 taken 416157 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 416157 times.
449603 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
13767 33446 return;
13768
13769
2/2
✓ Branch 0 taken 16836 times.
✓ Branch 1 taken 399321 times.
416157 if(clk3<=0)
13770 {
13771 16836 fix_coords(true);
13772
13773
2/2
✓ Branch 0 taken 4921 times.
✓ Branch 1 taken 11915 times.
16836 if(!dashing)
13774 {
13775 11915 int32_t ldir = lined_up(7,false);
13776
13777
4/4
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 10727 times.
✓ Branch 2 taken 1016 times.
✓ Branch 3 taken 172 times.
11915 if(ldir!=-1 && canmove(ldir,false))
13778 {
13779 1016 dir=ldir;
13780 1016 dashing=true;
13781 1016 step=zslongToFix(dstep*100)+1;
13782 1016 }
13783 10899 else newdir(4,0,0);
13784 11915 }
13785
13786
2/2
✓ Branch 0 taken 16211 times.
✓ Branch 1 taken 625 times.
16836 if(!canmove(dir,false))
13787 {
13788 625 step=zslongToFix(dstep*100);
13789 625 newdir();
13790 625 dashing=false;
13791 625 }
13792
13793 16836 zfix div = step;
13794
13795
1/2
✓ Branch 0 taken 16836 times.
✗ Branch 1 not taken.
16836 if(div == 0)
13796 div = 1;
13797
13798 16836 clk3=(int32_t)(16.0/div);
13799 16836 return;
13800 }
13801
13802 399321 move(step);
13803 399321 --clk3;
13804 454101 }
13805
13806 356583 void eStalfos::vire_hop()
13807 {
13808 //if ( sclk > 0 ) return; //Don't hop during knockback.
13809
13810 // if(dmisc9!=e9tPOLSVOICE)
13811 // {
13812 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13813 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
13814 // return; //the enemy should split if it is sliding!
13815 // //else sclk=0; //might need this here, too. -Z
13816 // }
13817
2/2
✓ Branch 0 taken 140019 times.
✓ Branch 1 taken 216564 times.
356583 if(dmisc9!=e9tPOLSVOICE)
13818 {
13819
2/2
✓ Branch 0 taken 135236 times.
✓ Branch 1 taken 4783 times.
140019 if(sclk!=0)
13820 {
13821
2/2
✓ Branch 0 taken 940 times.
✓ Branch 1 taken 3843 times.
4783 if (dmisc2==e2tSPLITHIT) return;
13822 //return;
13823 3843 }
13824 139079 }
13825 216564 else sclk=0;
13826
13827
8/12
✓ Branch 0 taken 355643 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 355643 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 348831 times.
✓ Branch 5 taken 6812 times.
✓ Branch 6 taken 339655 times.
✓ Branch 7 taken 9176 times.
✓ Branch 8 taken 339655 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 339655 times.
355643 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
13828 15988 return;
13829
13830 339655 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
13831 339655 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
13832
13833 339655 y=floor_y;
13834
13835
2/2
✓ Branch 0 taken 328455 times.
✓ Branch 1 taken 11200 times.
339655 if(clk3<=0)
13836 {
13837 11200 fix_coords();
13838
13839 //z=0;
13840 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
13841 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
13842
9/10
✓ Branch 0 taken 2307 times.
✓ Branch 1 taken 8893 times.
✓ Branch 2 taken 2051 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 1957 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
11200 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
13843 9243 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
13844
13845
2/2
✓ Branch 0 taken 2307 times.
✓ Branch 1 taken 8893 times.
11200 if(clk2<=0)
13846 {
13847 //z=0;
13848
6/6
✓ Branch 0 taken 8131 times.
✓ Branch 1 taken 762 times.
✓ Branch 2 taken 7922 times.
✓ Branch 3 taken 209 times.
✓ Branch 4 taken 5674 times.
✓ Branch 5 taken 2248 times.
8893 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
13849 {
13850
13851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6645 times.
6645 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
13852 /*if (dmisc9==e9tPOLSVOICE )
13853 {
13854 zprint2("polsvoice jump_width is: %d\n", jump_width);
13855 zprint2("polsvoice raw step is: %d\n", step);
13856 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
13857 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
13858 }
13859 else
13860 {
13861 zprint2("vire jump_width is: %d\n", jump_width);
13862 zprint2("vire raw step is: %d\n", step);
13863 zprint2("vire step.getInt() is: %d\n", step.getInt());
13864 zprint2("setting clk2 on vire to: %d\n", clk2);
13865 }
13866 */
13867 6645 }
13868 8893 }
13869
13870
4/4
✓ Branch 0 taken 4376 times.
✓ Branch 1 taken 6824 times.
✓ Branch 2 taken 2003 times.
✓ Branch 3 taken 2373 times.
11200 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
13871 {
13872 2373 clk2=int32_t((16.0*jump_width)/step.getFloat());
13873 2373 }
13874
13875 11200 clk3=int32_t(16.0/step.getFloat());
13876 11200 }
13877
13878 339655 --clk3;
13879
13880
3/4
✓ Branch 0 taken 131106 times.
✓ Branch 1 taken 208549 times.
✓ Branch 2 taken 131106 times.
✗ Branch 3 not taken.
339655 if(dmisc9==e9tPOLSVOICE || clk2>0)
13881 339655 move(step);
13882
13883 339655 floor_y=y;
13884 339655 clk2--;
13885
13886 //if we're in the middle of a jump
13887
6/6
✓ Branch 0 taken 262151 times.
✓ Branch 1 taken 77504 times.
✓ Branch 2 taken 111548 times.
✓ Branch 3 taken 150603 times.
✓ Branch 4 taken 53385 times.
✓ Branch 5 taken 58163 times.
339655 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
13888 {
13889 203988 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
13890
13891
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 106904 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
203988 if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
13892 {
13893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
13894 90933 else z=h;
13895 90933 }
13896 else
13897 {
13898 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
13899 //y-=h;
13900 113055 y=floor_y-h;
13901 113055 shadowdistance=h;
13902 }
13903 203988 }
13904 else
13905 135667 shadowdistance = 0;
13906 356583 }
13907
13908 47 void eStalfos::eathero()
13909 {
13910
5/8
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 28 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 28 times.
47 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
13911 {
13912 28 hashero=true;
13913 28 y=floor_y;
13914 28 z=0;
13915
13916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(Hero.isSwimming())
13917 {
13918 Hero.setX(x);
13919 Hero.setY(y);
13920 }
13921 else
13922 {
13923 28 x=Hero.getX();
13924 28 y=Hero.getY();
13925 }
13926
13927 28 clk2=0;
13928 28 }
13929 47 }
13930
13931 619142 bool eStalfos::WeaponOut()
13932 {
13933
2/2
✓ Branch 0 taken 1266387 times.
✓ Branch 1 taken 254405 times.
1520792 for(int32_t i=0; i<Ewpns.Count(); i++)
13934 {
13935
3/4
✓ Branch 0 taken 364737 times.
✓ Branch 1 taken 901650 times.
✓ Branch 2 taken 364737 times.
✗ Branch 3 not taken.
1266387 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
13936 {
13937 364737 return true;
13938 }
13939
13940 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
13941 stop_sfx(bgsfx);
13942 */
13943 901650 }
13944
13945 254405 return false;
13946 619142 }
13947
13948 156550 void eStalfos::KillWeapon()
13949 {
13950
2/2
✓ Branch 0 taken 156550 times.
✓ Branch 1 taken 169200 times.
325750 for(int32_t i=0; i<Ewpns.Count(); i++)
13951 {
13952
4/4
✓ Branch 0 taken 144447 times.
✓ Branch 1 taken 24753 times.
✓ Branch 2 taken 144005 times.
✓ Branch 3 taken 442 times.
169200 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
13953 {
13954 //only kill this Goriya's boomerang -DD
13955
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 182 times.
442 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
13956 {
13957 182 Ewpns.del(i);
13958 182 }
13959 442 }
13960 169200 }
13961
13962
4/4
✓ Branch 0 taken 13138 times.
✓ Branch 1 taken 143412 times.
✓ Branch 2 taken 6365 times.
✓ Branch 3 taken 6773 times.
156550 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
13963 {
13964 6365 stop_sfx(WAV_BRANG);
13965 6365 }
13966 156550 }
13967
13968 void eStalfos::break_shield()
13969 {
13970 if(!shield)
13971 return;
13972
13973 flags&=~(inv_front | inv_back | inv_left | inv_right);
13974 shield=false;
13975
13976 if(get_bit(quest_rules,qr_BRKNSHLDTILES))
13977 o_tile=s_tile;
13978 }
13979
13980 8964 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13981 8964 {
13982
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 dir=(zc_oldrand()&7)+8;
13983
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 step=0;
13984 4482 movestatus=1;
13985
3/4
✓ Branch 0 taken 3526 times.
✓ Branch 1 taken 956 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3526 times.
4482 if (dmisc1 != 1 && dmisc19 > 0)
13986 {
13987 step = dmisc19/100.0;
13988 movestatus = 1;
13989 }
13990
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 if (dmisc1 == 2) movestatus=2;
13991 4482 c=0;
13992 4482 SIZEflags = d->SIZEflags;
13993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
13994
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13995
13996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hxsz=12;
13997
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
13998
13999
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
14000
1/2
✓ Branch 0 taken 4482 times.
✗ Branch 1 not taken.
4482 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14001
14002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hysz=8;
14003
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14004
14005
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14006 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
14007 // al_trace("Enemy txsz:%i\n", txsz);
14008
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14009
14010
14011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14012
14013
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
14014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
4482 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14015 {
14016 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14017 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14018 }
14019
14020
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4482 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4482 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
14021 4482 clk4=0;
14022 //nets;
14023 4482 dummy_int[1]=0;
14024 4482 }
14025
14026 1377114 bool eKeese::animate(int32_t index)
14027 {
14028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377114 times.
1377114 if(switch_hooked) return enemy::animate(index);
14029
2/4
✓ Branch 0 taken 1377114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1377114 times.
1377114 if(fallclk||drownclk) return enemy::animate(index);
14030
2/2
✓ Branch 0 taken 52218 times.
✓ Branch 1 taken 1324896 times.
1377114 if(dying)
14031 52218 return Dead(index);
14032
14033
2/2
✓ Branch 0 taken 1317481 times.
✓ Branch 1 taken 7415 times.
1324896 if(clk==0)
14034 {
14035 7415 removearmos(x,y,ffcactivated);
14036 7415 }
14037
14038
2/2
✓ Branch 0 taken 368335 times.
✓ Branch 1 taken 956561 times.
1324896 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
14039 {
14040 368335 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
14041 368335 }
14042 else
14043 {
14044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 956561 times.
956561 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
14045 956561 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
14046 }
14047
14048
2/2
✓ Branch 0 taken 14165 times.
✓ Branch 1 taken 1310731 times.
1324896 if(dmisc2 == e2tKEESETRIB)
14049 {
14050
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14165 times.
✓ Branch 2 taken 14135 times.
✓ Branch 3 taken 30 times.
14165 if(++clk4==(dmisc20>0?dmisc20:256))
14051 {
14052
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 19 times.
30 if(!m_walkflag(x,y,0, dir))
14053 {
14054 19 int32_t kids = guys.Count();
14055 19 bool success = false;
14056 19 int32_t id2=dmisc3;
14057 19 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
14058
14059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if(success)
14060 {
14061
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 if(itemguy) // Hand down the carried item
14062 {
14063 guycarryingitem = guys.Count()-1;
14064 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
14065 itemguy = false;
14066 }
14067
14068 19 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
14069 19 }
14070
14071 19 stop_bgsfx(index);
14072 19 return true;
14073 }
14074 else
14075 {
14076 11 clk4=0;
14077 }
14078 11 }
14079 14146 }
14080 // Keese Tribbles stay on the ground, so there's no problem when they transform.
14081
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 827563 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1310731 else if(get_bit(quest_rules,qr_ENEMIESZAXIS) && !(isSideViewGravity()))
14082 {
14083
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_bit(quest_rules,qr_OLD_KEESE_Z_AXIS))
14084 {
14085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
14086 {
14087 fakez=int32_t(step/zslongToFix(dstep*100));
14088 // Some variance in keese flight heights when away from Hero
14089 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14090
14091 }
14092 else
14093 {
14094 483168 z=int32_t(step/zslongToFix(dstep*100));
14095 // Some variance in keese flight heights when away from Hero
14096
2/2
✓ Branch 0 taken 392397 times.
✓ Branch 1 taken 90771 times.
483168 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-128)/10));
14097 }
14098 483168 }
14099 else
14100 {
14101 if (moveflags & FLAG_USE_FAKE_Z)
14102 {
14103 fakez=int32_t(step/zslongToFix(dstep*100));
14104 // Some variance in keese flight heights when away from Hero
14105 fakez+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14106
14107 }
14108 else
14109 {
14110 z=int32_t(step/zslongToFix(dstep*100));
14111 // Some variance in keese flight heights when away from Hero
14112 z+=int32_t(step*zc_max(zfix(0),(distance(x,y,HeroX(),HeroY())-40)/4));
14113 }
14114 }
14115 483168 }
14116
14117 1324877 return enemy::animate(index);
14118 1377114 }
14119
14120 376313 void eKeese::drawshadow(BITMAP *dest, bool translucent)
14121 {
14122 376313 int32_t tempy=yofs;
14123 376313 flip = 0;
14124 376313 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
14125
14126
2/2
✓ Branch 0 taken 129846 times.
✓ Branch 1 taken 246467 times.
376313 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
14127
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 73791 times.
376313 if(!get_bit(quest_rules,qr_ENEMIESZAXIS))
14128 {
14129 73791 yofs+=int32_t(step/zslongToFix(dstep*10));
14130 73791 }
14131
14132
6/6
✓ Branch 0 taken 372719 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 70197 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
376313 if(!shadow_overpit(this) && (!get_bit(quest_rules,qr_ENEMIESZAXIS) || step > 0))
14133 364649 enemy::drawshadow(dest, translucent);
14134 376313 yofs=tempy;
14135 376313 }
14136
14137 3222716 void eKeese::draw(BITMAP *dest)
14138 {
14139 3222716 update_enemy_frame();
14140 3222716 enemy::draw(dest);
14141 3222716 }
14142
14143 10306 void eWizzrobe::submerge(bool set)
14144 {
14145
2/2
✓ Branch 0 taken 10278 times.
✓ Branch 1 taken 28 times.
10306 if(get_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING))
14146 {
14147 10278 hxofs = set?1000:0;
14148 10278 return;
14149 }
14150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
14151 28 submerged = set;
14152
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
14153 14 hxofs+=1000;
14154 14 else hxofs -= 1000;
14155 10306 }
14156 3324 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14157 3324 {
14158 1662 hxofs = 0;
14159 1662 submerged = false;
14160
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 1002 times.
1662 switch(dmisc1)
14161 {
14162 case 0:
14163
1/2
✓ Branch 0 taken 1002 times.
✗ Branch 1 not taken.
1002 submerge(true);
14164 1002 fading=fade_invisible;
14165 // Set clk to just before the 'reappear' threshold
14166
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1002 times.
✓ Branch 4 taken 801 times.
✓ Branch 5 taken 201 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 801 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 201 times.
1002 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
14167 1002 break;
14168
14169 default:
14170 660 dir=(loadside==right)?right:left;
14171 660 misc=-3;
14172 660 break;
14173 }
14174
14175 //netst+2880;
14176 1662 charging=false;
14177 1662 firing=false;
14178 1662 fclk=0;
14179
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 660 times.
1662 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
14180 1662 SIZEflags = d->SIZEflags;
14181
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14182 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14183 // al_trace("Enemy txsz:%i\n", txsz);
14184
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14185
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hxsz = d->hxsz;
14186
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hysz = d->hysz;
14187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
14188
1/2
✓ Branch 0 taken 1662 times.
✗ Branch 1 not taken.
1662 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
14189 {
14190 hxofs = (submerged?hxofs:0)+d->hxofs;
14191 }
14192
1/2
✓ Branch 0 taken 1662 times.
✗ Branch 1 not taken.
1662 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14193 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14194
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
1662 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14196 {
14197 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14198 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14199 }
14200
14201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1662 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1662 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
14202 1662 }
14203
14204 830438 bool eWizzrobe::animate(int32_t index)
14205 {
14206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 830438 times.
830438 if(switch_hooked) return enemy::animate(index);
14207
2/4
✓ Branch 0 taken 830438 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 830438 times.
830438 if(fallclk||drownclk) return enemy::animate(index);
14208
2/2
✓ Branch 0 taken 18856 times.
✓ Branch 1 taken 811582 times.
830438 if(dying)
14209 {
14210 18856 return Dead(index);
14211 }
14212
14213
2/2
✓ Branch 0 taken 786501 times.
✓ Branch 1 taken 25081 times.
811582 if(clk==0)
14214 {
14215 25081 removearmos(x,y,ffcactivated);
14216 25081 }
14217
14218
2/2
✓ Branch 0 taken 401978 times.
✓ Branch 1 taken 409604 times.
811582 if(dmisc1) // Floating
14219 {
14220 401978 wizzrobe_attack();
14221 401978 }
14222 else // Teleporting
14223 {
14224
5/6
✓ Branch 0 taken 404251 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 401541 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
409604 if(watch || (!get_bit(quest_rules, qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
14225 {
14226 5353 fading=0;
14227 5353 submerge(false);
14228 5353 solid_update(false);
14229 5353 }
14230
8/8
✓ Branch 0 taken 390812 times.
✓ Branch 1 taken 2397 times.
✓ Branch 2 taken 2096 times.
✓ Branch 3 taken 2026 times.
✓ Branch 4 taken 1991 times.
✓ Branch 5 taken 1717 times.
✓ Branch 6 taken 1658 times.
✓ Branch 7 taken 1554 times.
404251 else switch(clk)
14231 {
14232 case 0:
14233
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 1916 times.
2397 if(!dmisc2)
14234 {
14235 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
14236 // but should not appear on dungeon walls.
14237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1916 times.
1916 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
14238
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 1871 times.
1916 else if (editorflags&ENEMY_FLAG5)
14239 {
14240 //2.10 Windrobe
14241 //randomise location and face Hero
14242 45 int32_t t=0;
14243 45 bool placed=false;
14244
14245
4/4
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 45 times.
96 while(!placed && t<160)
14246 {
14247
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if(isdungeon())
14248 {
14249 51 x=((zc_oldrand()%12)+2)*16;
14250 51 y=((zc_oldrand()%7)+2)*16;
14251 51 }
14252 else
14253 {
14254 x=((zc_oldrand()%14)+1)*16;
14255 y=((zc_oldrand()%9)+1)*16;
14256 }
14257
14258
6/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 45 times.
101 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14259 {
14260 45 placed=true;
14261 45 }
14262
14263 51 ++t;
14264 }
14265
14266
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 31 times.
45 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14267 {
14268
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 5 times.
14 if(y<Hero.getY())
14269 {
14270 9 dir=down;
14271 9 }
14272 else
14273 {
14274 5 dir=up;
14275 }
14276 14 }
14277 else
14278 {
14279
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 15 times.
31 if(x<Hero.getX())
14280 {
14281 15 dir=right;
14282 15 }
14283 else
14284 {
14285 16 dir=left;
14286 }
14287 }
14288
14289
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!placed) // can't place him, he's gone
14290 return true;
14291
14292
14293 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
14294 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
14295 45 }
14296 1871 else place_on_axis(true, dmisc4!=0);
14297 1916 }
14298 else
14299 {
14300 481 int32_t t=0;
14301 481 bool placed=false;
14302
14303
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
14304 {
14305
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
14306 {
14307 624 x=((zc_oldrand()%12)+2)*16;
14308 624 y=((zc_oldrand()%7)+2)*16;
14309 624 }
14310 else
14311 {
14312 17 x=((zc_oldrand()%14)+1)*16;
14313 17 y=((zc_oldrand()%9)+1)*16;
14314 }
14315
14316
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
14317 {
14318 481 placed=true;
14319 481 }
14320
14321 641 ++t;
14322 }
14323
14324
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
14325 {
14326
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
14327 {
14328 97 dir=down;
14329 97 }
14330 else
14331 {
14332 62 dir=up;
14333 }
14334 159 }
14335 else
14336 {
14337
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
14338 {
14339 166 dir=right;
14340 166 }
14341 else
14342 {
14343 156 dir=left;
14344 }
14345 }
14346
14347
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
14348 return true;
14349 }
14350
14351 2397 fading=fade_flicker;
14352 2397 submerge(false);
14353 2397 solid_update(false);
14354 2397 break;
14355
14356 case 64:
14357 2096 fading=0;
14358 2096 charging=true;
14359 2096 break;
14360
14361 case 73:
14362 2026 charging=false;
14363 2026 firing=40;
14364 2026 break;
14365
14366 case 83:
14367 1991 wizzrobe_attack_for_real();
14368 1991 break;
14369
14370 case 119:
14371 1717 firing=false;
14372 1717 charging=true;
14373 1717 break;
14374
14375 case 128:
14376 1658 fading=fade_flicker;
14377 1658 charging=false;
14378 1658 break;
14379
14380 case 146:
14381 1554 fading=fade_invisible;
14382 1554 submerge(true);
14383 1554 solid_update(false);
14384
14385 [[fallthrough]];
14386 default:
14387
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 392366 times.
✓ Branch 2 taken 389965 times.
✓ Branch 3 taken 2401 times.
392366 if(clk>=(146+zc_max(0,dmisc5)))
14388 2401 clk=-1;
14389
14390 392366 break;
14391 }
14392 }
14393
14394 811582 return enemy::animate(index);
14395 830438 }
14396
14397 3249 void eWizzrobe::wizzrobe_attack_for_real()
14398 {
14399
1/2
✓ Branch 0 taken 3249 times.
✗ Branch 1 not taken.
3249 if(wpn==0) // Edited enemies
14400 return;
14401
14402
2/2
✓ Branch 0 taken 773 times.
✓ Branch 1 taken 2476 times.
3249 if(dmisc2 == 0) //normal weapon
14403 {
14404 2476 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
14405 2476 sfx(WAV_WAND,pan(int32_t(x)));
14406 2476 }
14407
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 450 times.
773 else if(dmisc2 == 1) // ring of fire
14408 {
14409 323 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
14410 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14411 323 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
14412 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14413 323 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
14414 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14415 323 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
14416 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14417 323 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
14418 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14419 323 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
14420 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14421 323 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
14422 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14423 323 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
14424 323 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
14425 323 sfx(WAV_FIRE,pan(int32_t(x)));
14426
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 283 times.
323 if (get_bit(quest_rules, qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
14427 else
14428 {
14429
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
14430 {
14431 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
14432
14433 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
14434 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
14435 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
14436 case ewRock: sfx(51,pan(int32_t(x))); break;
14437 case ewMagic: sfx(32,pan(int32_t(x))); break;
14438 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14439 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
14440 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14441 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
14442 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
14443 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
14444 case ewWind: sfx(32,pan(int32_t(x))); break;
14445 case ewFlame2: sfx(13,pan(int32_t(x))); break;
14446 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
14447 case ewIce: sfx(44,pan(int32_t(x))); break;
14448 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
14449 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
14450
14451 }
14452 }
14453 323 }
14454
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
14455 {
14456 436 int32_t bc=0;
14457
14458
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
14459 {
14460
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
14461 {
14462 2804 ++bc;
14463 2804 }
14464 5394 }
14465
14466
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
14467 {
14468 428 int32_t kids = guys.Count();
14469 428 int32_t bats=(zc_oldrand()%3)+1;
14470
14471
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
14472 {
14473 // Summon bats (or anything)
14474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
14475 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14476 868 }
14477
14478 428 sfx(WAV_FIRE,pan(int32_t(x)));
14479 428 }
14480 436 }
14481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
14482 {
14483
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
14484 {
14485 return;
14486 }
14487
14488 14 int32_t kids = guys.Count();
14489
14490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
14491 {
14492 14 int32_t newguys=(zc_oldrand()%3)+1;
14493 14 bool summoned=false;
14494
14495
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
14496 {
14497 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
14498 25 int32_t x2=0;
14499 25 int32_t y2=0;
14500
14501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
14502 {
14503 27 x2=16*((zc_oldrand()%12)+2);
14504 27 y2=16*((zc_oldrand()%7)+2);
14505
14506
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
14507 {
14508
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(addchild(x2,y2,get_bit(quest_rules,qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
14509 {
14510 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
14511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_bit(quest_rules,qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
14512 {
14513 ((enemy*)guys.spr(kids+i))->fakez = 64;
14514 ((enemy*)guys.spr(kids+i))->z = 0;
14515 }
14516 25 }
14517
14518 25 summoned=true;
14519 25 break;
14520 }
14521 2 }
14522 25 }
14523
14524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
14525 {
14526 14 sfx(get_bit(quest_rules,qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
14527 14 }
14528 14 }
14529 14 }
14530 3249 }
14531
14532
14533 401978 void eWizzrobe::wizzrobe_attack()
14534 {
14535
9/12
✓ Branch 0 taken 391428 times.
✓ Branch 1 taken 10550 times.
✓ Branch 2 taken 391428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 382265 times.
✓ Branch 5 taken 9163 times.
✓ Branch 6 taken 380114 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 380114 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 380114 times.
401978 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
14536 21864 return;
14537
14538
3/8
✓ Branch 0 taken 365267 times.
✓ Branch 1 taken 14847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 365267 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
380114 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
14539 {
14540 14847 fix_coords();
14541
14542
5/5
✓ Branch 0 taken 1668 times.
✓ Branch 1 taken 497 times.
✓ Branch 2 taken 7340 times.
✓ Branch 3 taken 3520 times.
✓ Branch 4 taken 1822 times.
14847 switch(misc)
14543 {
14544 case 1: //walking
14545
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 875 times.
3520 if(!m_walkflag(x,y,spw_door, dir))
14546 875 misc=0;
14547 else
14548 {
14549 2645 clk3=16;
14550
14551
2/2
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 313 times.
2645 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
14552 {
14553 313 wizzrobe_newdir(0);
14554 313 }
14555 }
14556
14557 3520 break;
14558
14559 case 2: //phasing
14560 {
14561 1822 int32_t jx=x;
14562 1822 int32_t jy=y;
14563 1822 int32_t jdir=-1;
14564
14565
5/5
✓ Branch 0 taken 929 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 212 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 228 times.
1822 switch(zc_oldrand()&7)
14566 {
14567 case 0:
14568 231 jx-=32;
14569 231 jy-=32;
14570 231 jdir=15;
14571 231 break;
14572
14573 case 1:
14574 212 jx+=32;
14575 212 jy-=32;
14576 212 jdir=9;
14577 212 break;
14578
14579 case 2:
14580 222 jx+=32;
14581 222 jy+=32;
14582 222 jdir=11;
14583 222 break;
14584
14585 case 3:
14586 228 jx-=32;
14587 228 jy+=32;
14588 228 jdir=13;
14589 228 break;
14590 }
14591
14592
10/10
✓ Branch 0 taken 893 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 792 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 738 times.
✓ Branch 5 taken 54 times.
✓ Branch 6 taken 638 times.
✓ Branch 7 taken 100 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 122 times.
1822 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
14593 {
14594 516 misc=3;
14595 516 clk3=32;
14596 516 dir=jdir;
14597 516 break;
14598 }
14599 1306 }
14600 [[fallthrough]];
14601 case 3:
14602 1803 dir&=3;
14603 1803 misc=0;
14604 [[fallthrough]];
14605 case 0:
14606 9143 wizzrobe_newdir(64);
14607 [[fallthrough]];
14608 default:
14609
2/2
✓ Branch 0 taken 9772 times.
✓ Branch 1 taken 1039 times.
10811 if(!canmove(dir,(zfix)1,spw_door,false))
14610 {
14611
2/2
✓ Branch 0 taken 990 times.
✓ Branch 1 taken 49 times.
1039 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
14612 {
14613 990 misc=1;
14614 990 clk3=16;
14615 990 }
14616 else
14617 {
14618 49 wizzrobe_newdir(64);
14619 49 misc=0;
14620 49 clk3=32;
14621 }
14622 1039 }
14623 else
14624 {
14625 9772 clk3=32;
14626 }
14627
14628 10811 break;
14629 }
14630
14631
2/2
✓ Branch 0 taken 13382 times.
✓ Branch 1 taken 1465 times.
14847 if(misc<0)
14632 1465 ++misc;
14633 14847 }
14634
14635 380114 --clk3;
14636
14637
3/3
✓ Branch 0 taken 73495 times.
✓ Branch 1 taken 276733 times.
✓ Branch 2 taken 29886 times.
380114 switch(misc)
14638 {
14639 case 1:
14640 case 3:
14641 73495 step=1;
14642 73495 break;
14643
14644 case 2:
14645 29886 step=0;
14646 29886 break;
14647
14648 default:
14649 276733 step=0.5;
14650 276733 break;
14651
14652 }
14653
14654 380114 move(step);
14655
14656 // if(d->misc1 && misc<=0 && clk3==28)
14657
5/6
✓ Branch 0 taken 380114 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276733 times.
✓ Branch 3 taken 103381 times.
✓ Branch 4 taken 267180 times.
✓ Branch 5 taken 9553 times.
380114 if(dmisc1 && misc<=0 && clk3==28)
14658 {
14659
2/2
✓ Branch 0 taken 8105 times.
✓ Branch 1 taken 1448 times.
9553 if(dmisc2 != 1)
14660 {
14661
2/2
✓ Branch 0 taken 7170 times.
✓ Branch 1 taken 935 times.
8105 if(lined_up(8,false) == dir)
14662 {
14663 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
14664 // sfx(WAV_WAND,pan(int32_t(x)));
14665 935 wizzrobe_attack_for_real();
14666 935 fclk=30;
14667 935 }
14668 8105 }
14669 else
14670 {
14671
2/2
✓ Branch 0 taken 1125 times.
✓ Branch 1 taken 323 times.
1448 if((zc_oldrand()%500)>=400)
14672 {
14673 323 wizzrobe_attack_for_real();
14674 323 fclk=30;
14675 323 }
14676 }
14677 9553 }
14678
14679
4/4
✓ Branch 0 taken 243713 times.
✓ Branch 1 taken 136401 times.
✓ Branch 2 taken 1863 times.
✓ Branch 3 taken 241850 times.
380114 if(misc==0 && (zc_oldrand()&127)==0)
14680 1863 misc=2;
14681
14682
4/4
✓ Branch 0 taken 31749 times.
✓ Branch 1 taken 348365 times.
✓ Branch 2 taken 30147 times.
✓ Branch 3 taken 1602 times.
380114 if(misc==2 && clk3==4)
14683 1602 fix_coords();
14684
14685
2/4
✓ Branch 0 taken 380114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 380114 times.
380114 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
14686 {
14687
2/2
✓ Branch 0 taken 344174 times.
✓ Branch 1 taken 35940 times.
380114 if(fclk>0)
14688 {
14689 35940 --fclk;
14690 35940 }
14691 380114 }
14692
14693 401978 }
14694
14695 9505 void eWizzrobe::wizzrobe_newdir(int32_t homing)
14696 {
14697 // Wizzrobes shouldn't move to the edge of the screen;
14698 // if they're already there, they should move toward the center
14699
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9501 times.
9505 if(x<32)
14700 4 dir=right;
14701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9501 times.
9501 else if(x>=224)
14702 dir=left;
14703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9501 times.
9501 else if(y<32)
14704 dir=down;
14705
1/2
✓ Branch 0 taken 9501 times.
✗ Branch 1 not taken.
9501 else if(y>=144)
14706 dir=up;
14707 else
14708 9501 newdir(4,homing,spw_wizzrobe);
14709 9505 }
14710
14711 831608 void eWizzrobe::draw(BITMAP *dest)
14712 {
14713 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
14714
13/14
✓ Branch 0 taken 408822 times.
✓ Branch 1 taken 422786 times.
✓ Branch 2 taken 348731 times.
✓ Branch 3 taken 60091 times.
✓ Branch 4 taken 39073 times.
✓ Branch 5 taken 369749 times.
✓ Branch 6 taken 38579 times.
✓ Branch 7 taken 494 times.
✓ Branch 8 taken 37822 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 36696 times.
✓ Branch 11 taken 1126 times.
✓ Branch 12 taken 36696 times.
✗ Branch 13 not taken.
831608 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
14715 36696 return;
14716
14717 794912 int32_t tempint=dummy_int[1];
14718 794912 bool tempbool1=dummy_bool[1];
14719 794912 bool tempbool2=dummy_bool[2];
14720 794912 dummy_int[1]=fclk;
14721 794912 dummy_bool[1]=charging;
14722 794912 dummy_bool[2]=firing;
14723 794912 update_enemy_frame();
14724 794912 dummy_int[1]=tempint;
14725 794912 dummy_bool[1]=tempbool1;
14726 794912 dummy_bool[2]=tempbool2;
14727 794912 enemy::draw(dest);
14728 831608 }
14729
14730 /*********************************/
14731 /********** Bosses ***********/
14732 /*********************************/
14733
14734 222 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14735 222 {
14736 111 fading=fade_flash_die;
14737 //nets+5120;
14738
6/8
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26 times.
✓ Branch 7 taken 3 times.
111 if(dir==down&&y>=128)
14739 {
14740 3 dir=up;
14741 3 }
14742
14743
5/8
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✗ Branch 7 not taken.
111 if(dir==right&&x>=208)
14744 {
14745 dir=left;
14746 }
14747 111 SIZEflags = d->SIZEflags;
14748
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14749 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14750 // al_trace("Enemy txsz:%i\n", txsz);
14751
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14752
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14753
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14754
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14755
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14756
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14757 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14758
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
111 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14760 {
14761 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14762 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14763 }
14764
14765
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
111 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14766 111 }
14767
14768 78920 bool eDodongo::animate(int32_t index)
14769 {
14770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78920 times.
78920 if(switch_hooked) return enemy::animate(index);
14771
2/2
✓ Branch 0 taken 2790 times.
✓ Branch 1 taken 76130 times.
78920 if(dying)
14772 {
14773 2790 return Dead(index);
14774 }
14775
14776
2/2
✓ Branch 0 taken 75788 times.
✓ Branch 1 taken 342 times.
76130 if(clk==0)
14777 {
14778 342 removearmos(x,y,ffcactivated);
14779 342 }
14780
14781
2/2
✓ Branch 0 taken 7104 times.
✓ Branch 1 taken 69026 times.
76130 if(clk2) // ate a bomb
14782 {
14783
2/2
✓ Branch 0 taken 7030 times.
✓ Branch 1 taken 74 times.
7104 if(--clk2==0)
14784 74 hp-=misc; // store bomb's power in misc
14785 7104 }
14786 else
14787 69026 constant_walk(rate,homing,spw_clipright);
14788
14789 76130 hxsz = (dir<=down) ? 16 : 32;
14790 // hysz = (dir>=left) ? 16 : 32;
14791
14792 76130 return enemy::animate(index);
14793 78920 }
14794
14795 78910 void eDodongo::draw(BITMAP *dest)
14796 {
14797 78910 tile=o_tile;
14798
14799
2/2
✓ Branch 0 taken 1833 times.
✓ Branch 1 taken 77077 times.
78910 if(clk<0)
14800 {
14801 1833 enemy::drawzcboss(dest);
14802 1833 return;
14803 }
14804
14805 77077 update_enemy_frame();
14806 77077 enemy::drawzcboss(dest);
14807
14808
2/2
✓ Branch 0 taken 30775 times.
✓ Branch 1 taken 46302 times.
77077 if(dummy_int[1]!=0) //additional tiles
14809 {
14810 46302 tile+=dummy_int[1]; //second tile is previous tile
14811 46302 xofs-=16; //new xofs change
14812 46302 enemy::drawzcboss(dest);
14813 46302 xofs+=16;
14814 46302 }
14815
14816 78910 }
14817
14818 4801 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
14819 {
14820 4801 int32_t wpnId = w->id;
14821 4801 int32_t power = w->power;
14822 4801 int32_t wpnx = w->x;
14823 4801 int32_t wpny = w->y;
14824
14825
5/12
✓ Branch 0 taken 4801 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4801 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1451 times.
✓ Branch 5 taken 3350 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1451 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
4801 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
14826 3350 return 0;
14827
14828
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 549 times.
✓ Branch 2 taken 817 times.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
1451 switch(wpnId)
14829 {
14830 case wPhantom:
14831 return 0;
14832
14833 case wFire:
14834 case wBait:
14835 case wWhistle:
14836 case wWind:
14837 case wSSparkle:
14838 case wFSparkle:
14839 return 0;
14840
14841 case wLitBomb:
14842 case wLitSBomb:
14843
6/6
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 371 times.
✓ Branch 2 taken 203 times.
✓ Branch 3 taken 346 times.
✓ Branch 4 taken 475 times.
✓ Branch 5 taken 74 times.
549 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
14844 475 return 0;
14845
14846 74 clk2=96;
14847 74 misc=power;
14848
14849
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 3 times.
74 if(wpnId==wLitSBomb)
14850 3 item_set=isSBOMB100;
14851
14852 74 return 1;
14853
14854 case wBomb:
14855 case wSBomb:
14856
6/6
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 257 times.
✓ Branch 3 taken 560 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 500 times.
817 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
14857 317 return 0;
14858
14859 500 stunclk=160;
14860 500 misc=wpnId; // store wpnId
14861 500 return 1;
14862
14863 case wSword:
14864
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 50 times.
72 if(stunclk)
14865 {
14866 50 sfx(WAV_EHIT,pan(int32_t(x)));
14867 50 hp=0;
14868 50 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
14869 50 fading=0; // don't flash
14870 50 return 1;
14871 }
14872
14873 [[fallthrough]];
14874 default:
14875 35 sfx(WAV_CHINK,pan(int32_t(x)));
14876 35 }
14877
14878 35 return 1;
14879 4801 }
14880
14881 4 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14882 4 {
14883 2 fading=fade_flash_die;
14884 //nets+5180;
14885 2 previous_dir=-1;
14886
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==down&&y>=128)
14887 {
14888 dir=up;
14889 }
14890
14891
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
14892 {
14893 dir=left;
14894 }
14895 2 SIZEflags = d->SIZEflags;
14896
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
14897 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
14898 // al_trace("Enemy txsz:%i\n", txsz);
14899
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
14900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
14901
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
14902
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
14903
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
14904
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
14905 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
14906
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
14907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
14908 {
14909 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
14910 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
14911 }
14912
14913
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
14914 2 }
14915
14916 848 bool eDodongo2::animate(int32_t index)
14917 {
14918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
14919
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
14920 {
14921 36 return Dead(index);
14922 }
14923
14924
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
14925 {
14926 4 removearmos(x,y,ffcactivated);
14927 4 }
14928
14929
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
14930 {
14931
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
14932 2 hp-=misc; // store bomb's power in misc
14933 192 }
14934 else
14935 620 constant_walk(rate,homing,spw_clipbottomright);
14936
14937 812 hxsz = (dir<=down) ? 16 : 32;
14938 812 hysz = (dir>=left) ? 16 : 32;
14939 812 hxofs=(dir>=left)?-8:0;
14940 812 hyofs=(dir<left)?-8:0;
14941
14942 812 return enemy::animate(index);
14943 848 }
14944
14945 848 void eDodongo2::draw(BITMAP *dest)
14946 {
14947
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
14948 {
14949 30 enemy::drawzcboss(dest);
14950 30 return;
14951 }
14952
14953 818 int32_t tempx=xofs;
14954 818 int32_t tempy=yofs;
14955 818 update_enemy_frame();
14956 818 enemy::drawzcboss(dest);
14957 818 tile+=dummy_int[1]; //second tile change
14958 818 xofs+=dummy_int[2]; //new xofs change
14959 818 yofs+=dummy_int[3]; //new yofs change
14960 818 enemy::drawzcboss(dest);
14961 818 xofs=tempx;
14962 818 yofs=tempy;
14963 848 }
14964
14965 165 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
14966 {
14967 165 int32_t wpnId = w->id;
14968 165 int32_t power = w->power;
14969 165 int32_t wpnx = w->x;
14970 165 int32_t wpny = w->y;
14971
14972
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
14973 145 return 0;
14974
14975
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
14976 {
14977 case wPhantom:
14978 return 0;
14979
14980 case wFire:
14981 case wBait:
14982 case wWhistle:
14983 case wWind:
14984 case wSSparkle:
14985 case wFSparkle:
14986 return 0;
14987
14988 case wLitBomb:
14989 case wLitSBomb:
14990
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
14991 {
14992 case up:
14993 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
14994 return 0;
14995
14996 break;
14997
14998 case down:
14999 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15000 return 0;
15001
15002 break;
15003
15004 case left:
15005
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15006 return 0;
15007
15008 2 break;
15009
15010 case right:
15011 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15012 return 0;
15013
15014 break;
15015 }
15016
15017 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
15018 // return 0;
15019 2 clk2=96;
15020 2 misc=power;
15021
15022
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
15023 item_set=isSBOMB100;
15024
15025 2 return 1;
15026
15027 case wBomb:
15028 case wSBomb:
15029
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
15030 {
15031 case up:
15032 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
15033 return 0;
15034
15035 break;
15036
15037 case down:
15038 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
15039 return 0;
15040
15041 break;
15042
15043 case left:
15044
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
15045 return 0;
15046
15047 15 break;
15048
15049 case right:
15050 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
15051 return 0;
15052
15053 break;
15054 }
15055
15056 15 stunclk=160;
15057 15 misc=wpnId; // store wpnId
15058 15 return 1;
15059
15060 case wSword:
15061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
15062 {
15063 2 sfx(WAV_EHIT,pan(int32_t(x)));
15064 2 hp=0;
15065 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
15066 2 fading=0; // don't flash
15067 2 return 1;
15068 }
15069
15070 [[fallthrough]];
15071 default:
15072 1 sfx(WAV_CHINK,pan(int32_t(x)));
15073 1 }
15074
15075 1 return 1;
15076 165 }
15077
15078 126 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
15079 126 {
15080 //these are here to bypass compiler warnings about unused arguments
15081
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if ( !(editorflags & ENEMY_FLAG5) )
15082 {
15083
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 x = dmisc1 ? 64 : 176;
15084
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 y = 64;
15085 63 }
15086 else { x = X; y = Y; }
15087
15088 //nets+5940;
15089
3/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 23 times.
63 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15090 {
15091 40 }
15092 else
15093 {
15094
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(dmisc1)
15095 {
15096 7 flip=1;
15097 7 }
15098 }
15099
15100
3/6
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
✓ Branch 4 taken 63 times.
✗ Branch 5 not taken.
63 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15101 63 clk3=32;
15102 63 clk2=0;
15103 63 clk4=clk;
15104 63 dir=left;
15105 63 SIZEflags = d->SIZEflags;
15106
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15107 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15108 // al_trace("Enemy txsz:%i\n", txsz);
15109
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15110
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15111
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15113
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15114
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15115 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15116
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15118 {
15119 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15120 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15121 }
15122
15123
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
63 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15124 63 }
15125
15126 40754 bool eAquamentus::animate(int32_t index)
15127 {
15128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40754 times.
40754 if(switch_hooked) return enemy::animate(index);
15129
2/2
✓ Branch 0 taken 1044 times.
✓ Branch 1 taken 39710 times.
40754 if(dying)
15130 1044 return Dead(index);
15131
15132 // fbx=x+((id==eRAQUAM)?4:-4);
15133
2/2
✓ Branch 0 taken 39532 times.
✓ Branch 1 taken 178 times.
39710 if(clk==0)
15134 {
15135 178 removearmos(x,y,ffcactivated);
15136 178 }
15137
15138 39710 fbx=x;
15139
15140 /*
15141 if (get_bit(quest_rules,qr_NEWENEMYTILES)&&id==eLAQUAM)
15142 {
15143 fbx+=16;
15144 }
15145 */
15146
2/2
✓ Branch 0 taken 39456 times.
✓ Branch 1 taken 254 times.
39710 if(--clk3==0)
15147 {
15148 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
15149 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
15150 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
15151 254 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
15152 254 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
15153 254 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
15154 254 sfx(wpnsfx(wpn),pan(int32_t(x)));
15155 254 }
15156
15157
4/4
✓ Branch 0 taken 12207 times.
✓ Branch 1 taken 27503 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 12007 times.
39710 if(clk3<-80 && !(zc_oldrand()&63))
15158 {
15159 200 clk3=32;
15160 200 }
15161
15162
2/2
✓ Branch 0 taken 39077 times.
✓ Branch 1 taken 633 times.
39710 if(!((clk4+1)&63))
15163 {
15164 633 int32_t d2=(zc_oldrand()%3)+1;
15165
15166
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 432 times.
633 if(d2>=left)
15167 {
15168 432 dir=d2;
15169 432 }
15170
15171
2/2
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 291 times.
633 if(dmisc1)
15172 {
15173
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 34 times.
342 if(x<=40)
15174 {
15175 34 dir=right;
15176 34 }
15177
15178
1/2
✓ Branch 0 taken 342 times.
✗ Branch 1 not taken.
342 if(x>=104)
15179 {
15180 dir=left;
15181 }
15182 342 }
15183 else
15184 {
15185
2/2
✓ Branch 0 taken 284 times.
✓ Branch 1 taken 7 times.
291 if(x<=136)
15186 {
15187 7 dir=right;
15188 7 }
15189
15190
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 14 times.
291 if(x>=200)
15191 {
15192 14 dir=left;
15193 14 }
15194 }
15195 633 }
15196
15197
4/4
✓ Branch 0 taken 38781 times.
✓ Branch 1 taken 929 times.
✓ Branch 2 taken 33906 times.
✓ Branch 3 taken 4875 times.
39710 if(clk4>=-1 && !((clk4+1)&7))
15198 {
15199
2/2
✓ Branch 0 taken 2553 times.
✓ Branch 1 taken 2322 times.
4875 if(dir==left)
15200 {
15201 2553 x-=1;
15202 2553 }
15203 else
15204 {
15205 2322 x+=1;
15206 }
15207 4875 }
15208
15209 39710 clk4=(clk4+1)%256;
15210
15211 39710 return enemy::animate(index);
15212 40754 }
15213
15214 41165 void eAquamentus::draw(BITMAP *dest)
15215 {
15216
2/2
✓ Branch 0 taken 25711 times.
✓ Branch 1 taken 15454 times.
41165 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15217 {
15218 25711 xofs=(dmisc1?-16:0);
15219
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25711 times.
✓ Branch 2 taken 10660 times.
✓ Branch 3 taken 15051 times.
25711 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
15220
15221
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 25063 times.
25711 if(dying)
15222 {
15223 648 xofs=0;
15224 648 enemy::draw(dest);
15225 648 }
15226 else
15227 {
15228 25063 drawblock(dest,15);
15229 }
15230 25711 }
15231 else
15232 {
15233 15454 int32_t xblockofs=((dmisc1)?-16:16);
15234 15454 xofs=0;
15235
15236
4/4
✓ Branch 0 taken 15109 times.
✓ Branch 1 taken 345 times.
✓ Branch 2 taken 396 times.
✓ Branch 3 taken 14713 times.
15454 if(clk<0 || dying)
15237 {
15238 741 enemy::draw(dest);
15239 741 return;
15240 }
15241
1/2
✓ Branch 0 taken 14713 times.
✗ Branch 1 not taken.
14713 if ( do_animation )
15242 {
15243 // face (0=firing, 2=resting)
15244 14713 tile=o_tile+((clk3>0)?0:2);
15245 14713 enemy::draw(dest);
15246 // tail (
15247 14713 tile=o_tile+((clk&16)?1:3);
15248 14713 xofs=xblockofs;
15249 14713 enemy::draw(dest);
15250 // body
15251 14713 yofs+=16;
15252 14713 xofs=0;
15253 14713 tile=o_tile+((clk&16)?20:22);
15254 14713 enemy::draw(dest);
15255 14713 xofs=xblockofs;
15256 14713 tile=o_tile+((clk&16)?21:23);
15257 14713 enemy::draw(dest);
15258 14713 yofs-=16;
15259 14713 }
15260 else enemy::draw(dest);
15261 }
15262 41165 }
15263
15264 8292 bool eAquamentus::hit(weapon *w)
15265 {
15266
3/6
✓ Branch 0 taken 8292 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8292 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8292 times.
8292 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
15267
15268
2/2
✓ Branch 0 taken 2698 times.
✓ Branch 1 taken 5594 times.
8292 switch(w->id)
15269 {
15270 case wBeam:
15271 case wRefBeam:
15272 case wMagic:
15273 2698 hysz=32;
15274 2698 }
15275
15276
4/4
✓ Branch 0 taken 8171 times.
✓ Branch 1 taken 121 times.
✓ Branch 2 taken 6234 times.
✓ Branch 3 taken 1937 times.
8292 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
15277 8292 hysz=16;
15278 8292 return ret;
15279
15280 8292 }
15281
15282 88 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
15283 88 {
15284
15285
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( !(editorflags & ENEMY_FLAG5) )
15286 {
15287
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 x = 128;
15288
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 y = 48;
15289 44 }
15290 else { x = X; y = Y; }
15291
15292 44 Clk=Clk;
15293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(flags & guy_fadeflicker)
15294 {
15295 clk=0;
15296 superman = 1;
15297 fading=fade_flicker;
15298 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
15299 }
15300
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 36 times.
44 else if(flags & guy_fadeinstant)
15301 {
15302 36 clk=0;
15303 36 }
15304 44 hxofs=-16;
15305 44 hxsz=48;
15306 44 clk4=0;
15307
3/6
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
44 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
15308
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 dir=zc_oldrand()%3+1;
15309 44 SIZEflags = d->SIZEflags;
15310
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15311 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15312 // al_trace("Enemy txsz:%i\n", txsz);
15313
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
15314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
15315
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
15316
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
15317
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
15318
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
15319 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15320
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
15321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15322 {
15323 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
15324 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15325 }
15326
15327
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
44 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
15328
15329 //nets+5340;
15330 44 }
15331
15332 41378 bool eGohma::animate(int32_t index)
15333 {
15334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41378 times.
41378 if(switch_hooked) return enemy::animate(index);
15335
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 40802 times.
41378 if(dying)
15336 576 return Dead(index);
15337
15338
1/2
✓ Branch 0 taken 40802 times.
✗ Branch 1 not taken.
40802 if(fading)
15339 {
15340 if(++clk4 > 60)
15341 {
15342 clk4=0;
15343 superman=0;
15344 fading=0;
15345 clk=0;
15346
15347 }
15348 else return enemy::animate(index);
15349 }
15350
15351
2/2
✓ Branch 0 taken 40622 times.
✓ Branch 1 taken 180 times.
40802 if(clk==0)
15352 {
15353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if (ffcactivated) removearmosffc(ffcactivated-1);
15354 else
15355 {
15356
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 removearmos(zc_max(x-16, zfix(0)),y);
15357 180 did_armos = false;
15358 180 removearmos(x,y);
15359 180 did_armos = false;
15360
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 removearmos(zc_min(x+16, zfix(255)),y);
15361 }
15362 180 }
15363
15364
2/2
✓ Branch 0 taken 40682 times.
✓ Branch 1 taken 120 times.
40802 if(clk<0) return enemy::animate(index);
15365
15366 // Movement clk must be separate from animation clk because of the Clock item
15367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40682 times.
40682 if(!watch)
15368 40682 clk4++;
15369
15370
2/2
✓ Branch 0 taken 40067 times.
✓ Branch 1 taken 615 times.
40682 if((clk4&63)==0)
15371 {
15372
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 295 times.
615 if(clk4&64)
15373 320 dir^=1;
15374 else
15375 295 dir=zc_oldrand()%3+1;
15376 615 }
15377
15378
2/2
✓ Branch 0 taken 40026 times.
✓ Branch 1 taken 656 times.
40682 if((clk&63)==3)
15379 {
15380
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 187 times.
656 switch(dmisc1)
15381 {
15382 case 1:
15383 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
15384 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15385 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
15386 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
15387 187 break;
15388
15389 default:
15390
3/4
✓ Branch 0 taken 469 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 384 times.
469 if(dmisc1 != 1 && dmisc1 != 2)
15391 {
15392 384 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
15393 384 sfx(wpnsfx(wpn),pan(int32_t(x)));
15394 384 sfx(wpnsfx(wpn),pan(int32_t(x)));
15395 384 }
15396
15397 469 break;
15398 }
15399 656 }
15400
15401
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 35326 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
40682 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
15402 {
15403
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
15404 {
15405 183 FireBreath(true);
15406 183 }
15407 1392 }
15408
15409
2/2
✓ Branch 0 taken 20331 times.
✓ Branch 1 taken 20351 times.
40682 if(clk4&1)
15410 20351 move((zfix)1);
15411
15412
2/2
✓ Branch 0 taken 40591 times.
✓ Branch 1 taken 91 times.
40682 if(++clk3>=400)
15413 91 clk3=0;
15414
15415 40682 return enemy::animate(index);
15416 41378 }
15417
15418 41376 void eGohma::draw(BITMAP *dest)
15419 {
15420 41376 tile=o_tile;
15421
15422
4/4
✓ Branch 0 taken 41256 times.
✓ Branch 1 taken 120 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 40680 times.
41376 if(clk<0 || dying)
15423 {
15424 696 enemy::drawzcboss(dest);
15425 696 return;
15426 }
15427
15428
2/2
✓ Branch 0 taken 33103 times.
✓ Branch 1 taken 7577 times.
40680 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15429 {
15430 ///if ( do_animation )
15431 //Yuck. Gohma can just not have this capability right now.
15432 // left side
15433 33103 xofs=-16;
15434 33103 flip=0;
15435 // if(clk&16) tile=180;
15436 // else { tile=182; flip=1; }
15437 33103 tile+=(3*((clk&48)>>4));
15438 33103 enemy::drawzcboss(dest);
15439
15440 // right side
15441 33103 xofs=16;
15442 // tile=(180+182)-tile;
15443 33103 tile=o_tile;
15444 33103 tile+=(3*((clk&48)>>4))+2;
15445 33103 enemy::drawzcboss(dest);
15446
15447 // body
15448 33103 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
15449 33103 tile=o_tile;
15450
15451 // tile+=(3*((clk&24)>>3))+2;
15452
2/2
✓ Branch 0 taken 1743 times.
✓ Branch 1 taken 31360 times.
33103 if(clk3<16)
15453 1743 tile+=7;
15454
2/2
✓ Branch 0 taken 9362 times.
✓ Branch 1 taken 21998 times.
31360 else if(clk3<116)
15455 9362 tile+=10;
15456
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
15457 1315 tile+=7;
15458 else
15459 20683 tile+=((clk3-132)&24)?4:1;
15460
15461 33103 enemy::drawzcboss(dest);
15462
15463 33103 }
15464 else
15465 {
15466 // left side
15467 7577 xofs=-16;
15468 7577 flip=0;
15469
15470
2/2
✓ Branch 0 taken 3750 times.
✓ Branch 1 taken 3827 times.
7577 if(!(clk&16))
15471 {
15472 3827 tile+=2;
15473 3827 flip=1;
15474 3827 }
15475
15476 7577 enemy::draw(dest);
15477
15478 // right side
15479 7577 tile=o_tile;
15480 7577 xofs=16;
15481
15482
2/2
✓ Branch 0 taken 3827 times.
✓ Branch 1 taken 3750 times.
7577 if((clk&16)) tile+=2;
15483
15484 // tile=(180+182)-tile;
15485 7577 enemy::draw(dest);
15486
15487 // body
15488 7577 tile=o_tile;
15489 7577 xofs=0;
15490
15491
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 7161 times.
7577 if(clk3<16)
15492 416 tile+=4;
15493
2/2
✓ Branch 0 taken 2279 times.
✓ Branch 1 taken 4882 times.
7161 else if(clk3<116)
15494 2279 tile+=5;
15495
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 4585 times.
4882 else if(clk3<132)
15496 297 tile+=4;
15497 4585 else tile+=((clk3-132)&8)?3:1;
15498
15499 7577 enemy::draw(dest);
15500
15501 }
15502 41376 }
15503
15504 203 int32_t eGohma::takehit(weapon *w, weapon* realweap)
15505 {
15506 203 int32_t wpnId = w->id;
15507 203 int32_t power = w->power;
15508 203 int32_t wpnx = w->x;
15509 203 int32_t wpnDir = w->dir;
15510 203 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
15511
15512
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 92 times.
203 if(def < 0)
15513 {
15514
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 67 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 59 times.
✓ Branch 9 taken 8 times.
92 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
15515 {
15516 33 sfx(WAV_CHINK,pan(int32_t(x)));
15517 33 return 1;
15518 }
15519 59 }
15520
15521 170 return enemy::takehit(w, realweap);
15522 203 }
15523
15524 354 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15525 354 {
15526 177 count_enemy=(id==(id&0xFFF));
15527 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
15528 177 SIZEflags = d->SIZEflags;
15529
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15530 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15531 // al_trace("Enemy txsz:%i\n", txsz);
15532
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15534
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15535
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15536
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15537
1/2
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
177 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15538 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15539
1/4
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15540
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15541 {
15542 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15543 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15544 }
15545
15546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
177 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15547 177 }
15548
15549 63881 bool eLilDig::animate(int32_t index)
15550 {
15551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63881 times.
63881 if(switch_hooked) return enemy::animate(index);
15552
2/2
✓ Branch 0 taken 2646 times.
✓ Branch 1 taken 61235 times.
63881 if(dying)
15553 2646 return Dead(index);
15554
15555
2/2
✓ Branch 0 taken 3228 times.
✓ Branch 1 taken 58007 times.
61235 if(clk==0)
15556 {
15557 3228 removearmos(x,y,ffcactivated);
15558 3228 }
15559
15560
2/2
✓ Branch 0 taken 40187 times.
✓ Branch 1 taken 21048 times.
61235 if(misc<=128)
15561 {
15562
2/2
✓ Branch 0 taken 633 times.
✓ Branch 1 taken 20415 times.
21048 if(!(++misc&31))
15563 633 step+=0.25;
15564 21048 }
15565
15566 61235 variable_walk_8(rate,homing,hrate,spw_floater);
15567 61235 return enemy::animate(index);
15568 63881 }
15569
15570 63749 void eLilDig::draw(BITMAP *dest)
15571 {
15572 63749 tile = o_tile;
15573 // tile = 160;
15574 63749 int32_t fdiv = frate/4;
15575
1/2
✓ Branch 0 taken 63749 times.
✗ Branch 1 not taken.
63749 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15576
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 17438 times.
63749 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15577 63749 efrate:((clk>=(frate>>1))?1:0);
15578
15579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63749 times.
63749 if ( do_animation )
15580 {
15581
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 17438 times.
63749 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15582 {
15583
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5035 times.
✓ Branch 8 taken 5312 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
15584 {
15585 case up: //u
15586 5853 flip=0;
15587 5853 break;
15588
15589 case l_up: //d
15590 5465 flip=0;
15591 5465 tile+=4;
15592 5465 break;
15593
15594 case l_down: //l
15595 5245 flip=0;
15596 5245 tile+=8;
15597 5245 break;
15598
15599 case left: //r
15600 5717 flip=0;
15601 5717 tile+=12;
15602 5717 break;
15603
15604 case r_down: //ul
15605 5242 flip=0;
15606 5242 tile+=20;
15607 5242 break;
15608
15609 case down: //ur
15610 4505 flip=0;
15611 4505 tile+=24;
15612 4505 break;
15613
15614 case r_up: //dl
15615 3937 flip=0;
15616 3937 tile+=28;
15617 3937 break;
15618
15619 case right: //dr
15620 5035 flip=0;
15621 5035 tile+=32;
15622 5035 break;
15623 }
15624
15625 46311 tile+=f2;
15626 46311 }
15627 else
15628 {
15629 17438 tile+=(clk>=6)?1:0;
15630 }
15631 63749 }
15632
15633 63749 enemy::draw(dest);
15634 63749 }
15635
15636 76 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15637 76 {
15638 38 superman=1;
15639
15640 38 SIZEflags = d->SIZEflags;
15641
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15642 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15643 // al_trace("Enemy txsz:%i\n", txsz);
15644
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15645
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
15646 38 else hxsz=32;
15647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
15648 38 else hysz=32;
15649
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15650 38 else hzsz=16; // hard to jump.
15651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15652 38 else hxofs=-8;
15653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15654 38 else hyofs=-8;
15655 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15656
1/4
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15658 {
15659 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
15660 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
15661 }
15662
15663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15664
15665
15666 38 }
15667
15668 14929 bool eBigDig::animate(int32_t index)
15669 {
15670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14929 times.
14929 if(switch_hooked) return enemy::animate(index);
15671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14929 times.
14929 if(dying)
15672 return Dead(index);
15673
15674
2/2
✓ Branch 0 taken 12960 times.
✓ Branch 1 taken 1969 times.
14929 if(clk==0)
15675 {
15676 1969 removearmos(x,y,ffcactivated);
15677 1969 }
15678
15679
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14859 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 35 times.
14929 switch(misc)
15680 {
15681 case 0:
15682 14859 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
15683 14859 break;
15684
15685 case 1:
15686 35 ++misc;
15687 35 break;
15688
15689 case 2:
15690
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 35 times.
137 for(int32_t i=0; i<dmisc5; i++)
15691 {
15692 102 addenemy(x,y,dmisc1+0x1000,-15);
15693 102 }
15694
15695
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 35 times.
45 for(int32_t i=0; i<dmisc6; i++)
15696 {
15697 10 addenemy(x,y,dmisc2+0x1000,-15);
15698 10 }
15699
15700
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 35 times.
45 for(int32_t i=0; i<dmisc7; i++)
15701 {
15702 10 addenemy(x,y,dmisc3+0x1000,-15);
15703 10 }
15704
15705
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 35 times.
45 for(int32_t i=0; i<dmisc8; i++)
15706 {
15707 10 addenemy(x,y,dmisc4+0x1000,-15);
15708 10 }
15709
15710
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(itemguy) // Hand down the carried item
15711 {
15712 guycarryingitem = guys.Count()-1;
15713 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
15714 itemguy = false;
15715 }
15716
15717 35 stop_bgsfx(index);
15718
15719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
15720
15721 35 return true;
15722 }
15723
15724 14894 return enemy::animate(index);
15725 14929 }
15726
15727 14924 void eBigDig::draw(BITMAP *dest)
15728 {
15729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14924 times.
14924 if(anim!=aDIG)
15730 {
15731 update_enemy_frame();
15732 xofs-=8;
15733 yofs-=8;
15734 drawblock(dest,15);
15735 xofs+=8;
15736 yofs+=8;
15737 return;
15738 }
15739
15740 14924 tile = o_tile;
15741 14924 int32_t fdiv = frate/4;
15742
1/2
✓ Branch 0 taken 14924 times.
✗ Branch 1 not taken.
14924 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15743
15744
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 4686 times.
14924 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
15745 14924 efrate:((clk>=(frate>>1))?1:0);
15746
15747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14924 times.
14924 if ( do_animation )
15748 {
15749
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 4686 times.
14924 if(get_bit(quest_rules,qr_NEWENEMYTILES))
15750 {
15751
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
15752 {
15753 case up: //u
15754 1115 flip=0;
15755 1115 break;
15756
15757 case l_up: //d
15758 1221 flip=0;
15759 1221 tile+=8;
15760 1221 break;
15761
15762 case l_down: //l
15763 1344 flip=0;
15764 1344 tile+=40;
15765 1344 break;
15766
15767 case left: //r
15768 1195 flip=0;
15769 1195 tile+=48;
15770 1195 break;
15771
15772 case r_down: //ul
15773 1233 flip=0;
15774 1233 tile+=80;
15775 1233 break;
15776
15777 case down: //ur
15778 1223 flip=0;
15779 1223 tile+=88;
15780
15781 1223 break;
15782
15783 case r_up: //dl
15784 993 flip=0;
15785 993 tile+=120;
15786 993 break;
15787
15788 case right: //dr
15789 1450 flip=0;
15790 1450 tile+=128;
15791 1450 break;
15792 }
15793
15794 10238 tile+=(f2*2);
15795 10238 }
15796 else
15797 {
15798 4686 tile+=(f2)?0:2;
15799 4686 flip=(clk&1)?1:0;
15800 }
15801 14924 }
15802
15803 14924 xofs-=8;
15804 14924 yofs-=8;
15805 14924 drawblock(dest,15);
15806 14924 xofs+=8;
15807 14924 yofs+=8;
15808 14924 }
15809
15810 269 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
15811 {
15812 269 int32_t wpnId = w->id;
15813
15814
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 234 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
269 if(wpnId==wWhistle && misc==0)
15815 35 misc=1;
15816
15817 269 return 0;
15818 }
15819
15820 /*
15821 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15822 {
15823 hxofs=hyofs=8;
15824 hzsz=16; //can't be jumped.
15825 clk2=70;
15826 misc=-1;
15827 mainguy=!getmapflag();
15828 }
15829
15830 bool eGanon::animate(int32_t index)
15831 {
15832 if(switch_hooked) return enemy::animate(index);
15833 if(dying)
15834
15835 return Dead(index);
15836
15837 if(clk==0)
15838 {
15839 removearmos(x,y,ffcactivated);
15840 }
15841
15842 switch(misc)
15843 {
15844 case -1:
15845 misc=0;
15846
15847 case 0:
15848 if(++clk2>72 && !(zc_oldrand()&3))
15849 {
15850 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
15851 sfx(wpnsfx(wpn),pan(int32_t(x)));
15852 clk2=0;
15853 }
15854
15855 Stunclk=0;
15856 constant_walk(rate,homing,spw_none);
15857 break;
15858
15859 case 1:
15860 case 2:
15861 if(--Stunclk<=0)
15862 {
15863 int32_t r=zc_oldrand();
15864
15865 if(r&1)
15866 {
15867 y=96;
15868
15869 if(r&2)
15870 x=160;
15871 else
15872 x=48;
15873
15874 if(tooclose(x,y,48))
15875 x=208-x;
15876 }
15877
15878 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
15879 //{
15880 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15881 // }
15882 // else
15883 // {
15884 loadpalset(csBOSS,pSprite(d->bosspal));
15885 // }
15886 misc=0;
15887 }
15888
15889 break;
15890
15891 case 3:
15892 {
15893 if(hclk>0)
15894 break;
15895
15896 misc=4;
15897 clk=0;
15898 hxofs=1000;
15899 loadpalset(9,pSprite(spPILE));
15900 music_stop();
15901 stop_sfx(WAV_ROAR);
15902
15903 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
15904
15905 sfx(WAV_GANON);
15906 //Ganon's dustpile; fall in sideview. -Z
15907 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
15908 dustpile->linked_parent = eeGANON;
15909 setmapflag();
15910 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
15911 break;
15912 }
15913
15914 case 4:
15915 if(clk>=80)
15916 {
15917 misc=5;
15918
15919 if(getmapflag())
15920 {
15921 game->lvlitems[dlevel]|=liBOSS;
15922 //play_DmapMusic();
15923 playLevelMusic();
15924 return true;
15925 }
15926
15927 sfx(WAV_CLEARED);
15928 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
15929 setmapflag();
15930 }
15931
15932 break;
15933 }
15934
15935 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
15936 //{
15937 //if ( current_item_id(itype_amulet,false) >= 2 )
15938 //{
15939 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
15940 //}
15941 //}
15942
15943
15944 return enemy::animate(index);
15945 }
15946
15947
15948 int32_t eGanon::takehit(weapon *w, weapon* realweap)
15949 {
15950 //these are here to bypass compiler warnings about unused arguments
15951 int32_t wpnId = w->id;
15952 int32_t power = w->power;
15953 int32_t enemyHitWeapon = w->parentitem;
15954
15955 switch(misc)
15956 {
15957 case 0:
15958 {
15959 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
15960 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
15961 return 0;
15962
15963 //if we are not using the new defences, just reduce his HP
15964 if (!(editorflags & ENEMY_FLAG14))
15965 {
15966 hp-=power;
15967 if(hp>0)
15968 {
15969 misc=1;
15970 Stunclk=64;
15971 }
15972 else
15973 {
15974 loadpalset(csBOSS,pSprite(spBROWN));
15975 misc=2;
15976 Stunclk=284;
15977 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
15978 }
15979
15980 sfx(WAV_EHIT,pan(int32_t(x)));
15981
15982 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
15983
15984 return 1;
15985 }
15986 //otherwise, resolve his defence.
15987 else
15988 {
15989 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
15990 if(hp>0)
15991 {
15992 misc=1;
15993 Stunclk=64;
15994 }
15995 else
15996 {
15997 loadpalset(csBOSS,pSprite(spBROWN));
15998 misc=2;
15999 Stunclk=284;
16000 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16001 }
16002
16003 sfx(WAV_EHIT,pan(int32_t(x)));
16004
16005 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16006
16007
16008 return 1;
16009 }
16010 }
16011 case 2:
16012 {
16013 if
16014 (
16015 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
16016 || //or nothing specified, use silver arrows+
16017 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
16018 )
16019 return 0;
16020 {
16021 misc=3;
16022 hclk=81;
16023 loadpalset(9,pSprite(spBROWN));
16024 return 1;
16025 }
16026
16027 }
16028 }
16029
16030 return 0;
16031 }
16032
16033 void eGanon::draw(BITMAP *dest)
16034 {
16035 switch(misc)
16036 {
16037 case 0:
16038 if((clk&3)==3)
16039 tile=(zc_oldrand()%5)*2+o_tile;
16040
16041 if(db!=999)
16042 break;
16043
16044 case 2:
16045 if(Stunclk<64 && (Stunclk&1) )
16046 {
16047 if
16048 (
16049 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16050 ||
16051 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16052 )
16053 {
16054 goto ganon_draw; //draw his weapons if we can see him
16055 }
16056 break;
16057 }
16058
16059 case -1:
16060 tile=o_tile;
16061
16062 //fall through
16063 case 1:
16064 case 3:
16065 ganon_draw:
16066 drawblock(dest,15);
16067 break;
16068
16069 case 4:
16070 draw_guts(dest);
16071 draw_flash(dest);
16072 break;
16073 }
16074
16075 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
16076 {
16077 if
16078 (
16079 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
16080 ||
16081 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
16082 )
16083 {
16084 draw_guts(dest); //makes his shots visible, but not him
16085 draw_flash(dest);
16086 }
16087 }
16088 }
16089
16090 void eGanon::draw_guts(BITMAP *dest)
16091 {
16092 int32_t c = zc_min(clk>>3,8);
16093 tile = clk<24 ? 74 : 75;
16094 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16095 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16096 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16097 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16098 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16099 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16100 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16101 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16102 }
16103
16104 void eGanon::draw_flash(BITMAP *dest)
16105 {
16106
16107 int32_t c = clk-(clk>>2);
16108 cs = (frame&3)+6;
16109 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16110 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16111 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16112 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16113 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16114 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16115 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16116 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16117 }
16118 */
16119
16120 12 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16121 12 {
16122 6 hxofs=hyofs=8;
16123
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if (editorflags & ENEMY_FLAG3)
16124 {
16125 hxofs = 4;
16126 hyofs = 4;
16127 hxsz = 24;
16128 hysz = 24;
16129 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
16130 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
16131 }
16132 6 hzsz=16; //can't be jumped.
16133 6 clk2=70;
16134 6 misc=-1;
16135
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 mainguy=(!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
16136 6 }
16137
16138 9583 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
16139 {
16140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9583 times.
9583 if(dying)
16141
16142 return Dead(index);
16143
16144
2/2
✓ Branch 0 taken 9546 times.
✓ Branch 1 taken 37 times.
9583 if(clk==0)
16145 {
16146 37 removearmos(x,y,ffcactivated);
16147 37 }
16148
16149
6/7
✓ Branch 0 taken 1754 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6847 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 492 times.
✓ Branch 5 taken 480 times.
✓ Branch 6 taken 4 times.
9583 switch(misc)
16150 {
16151 case -1:
16152 6 misc=0;
16153 [[fallthrough]];
16154 case 0:
16155
4/4
✓ Branch 0 taken 373 times.
✓ Branch 1 taken 6480 times.
✓ Branch 2 taken 279 times.
✓ Branch 3 taken 94 times.
6853 if(++clk2>72 && !(zc_oldrand()&3))
16156 {
16157 94 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16158 94 sfx(wpnsfx(wpn),pan(int32_t(x)));
16159 94 clk2=0;
16160 94 }
16161
16162 6853 Stunclk=0;
16163 6853 constant_walk(rate,homing,spw_none);
16164 6853 break;
16165
16166 case 1:
16167 case 2:
16168
2/2
✓ Branch 0 taken 1733 times.
✓ Branch 1 taken 21 times.
1754 if(--Stunclk<=0)
16169 {
16170 21 int32_t r=zc_oldrand();
16171
16172
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 9 times.
21 if(r&1)
16173 {
16174 9 y=96;
16175
16176
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if(r&2)
16177 2 x=160;
16178 else
16179 7 x=48;
16180
16181
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2 times.
9 if(tooclose(x,y,48))
16182 2 x=208-x;
16183 9 }
16184
16185 21 loadpalset(csBOSS,pSprite(d->bosspal));
16186 21 misc=0;
16187 21 }
16188
16189 1754 break;
16190
16191 case 3:
16192 {
16193
2/2
✓ Branch 0 taken 486 times.
✓ Branch 1 taken 6 times.
492 if(hclk>0)
16194 486 break;
16195
16196 6 misc=4;
16197 6 clk=0;
16198 6 hxofs=1000;
16199 6 loadpalset(9,pSprite(spPILE));
16200 6 music_stop();
16201 6 stop_sfx(WAV_ROAR);
16202
16203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
16204
16205 6 sfx(WAV_GANON);
16206 //Ganon's dustpile; fall in sideview. -Z
16207 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
16208 //dustpile->miscellaneous[31] = eeGANON;
16209
6/12
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
6 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16210 6 item *dustpile = NULL;
16211 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
16212 6 dustpile = (item *)items.spr(items.Count() - 1);
16213 6 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
16214 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
16215 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
16216 6 break;
16217 }
16218
16219 case 4:
16220
2/2
✓ Branch 0 taken 474 times.
✓ Branch 1 taken 6 times.
480 if(clk>=80)
16221 {
16222 6 misc=5;
16223
16224 //game->lvlitems[dlevel]|=liBOSS;
16225
16226 6 sfx(WAV_CLEARED);
16227 //Add the big TF over the ashes!
16228
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6 times.
18 for(word q = 0; q < items.Count(); q++)
16229 {
16230 12 item *ashes = (item*)items.spr(q);
16231
3/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
12 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
16232 {
16233 //Z_scripterrlog("Found correct dustpile!\n");
16234
4/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
6 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
16235 6 item *bigtriforce = NULL;
16236 6 bigtriforce = (item *)items.spr(items.Count() - 1);
16237 6 bigtriforce->linked_parent = eeGANON;
16238 6 }
16239 12 }
16240 //setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16241 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
16242 6 }
16243
16244 480 break;
16245 4 case 5: return true;
16246 }
16247
16248 9579 return enemy::animate(index);
16249 9583 }
16250
16251
16252 524 int32_t eGanon::takehit(weapon *w, weapon* realweap)
16253 {
16254 //these are here to bypass compiler warnings about unused arguments
16255 524 int32_t wpnId = w->id;
16256 524 int32_t power = w->power;
16257 524 int32_t enemyHitWeapon = w->parentitem;
16258
16259
3/3
✓ Branch 0 taken 426 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 71 times.
524 switch(misc)
16260 {
16261 case 0:
16262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(wpnId!=wSword)
16263 return 0;
16264
16265 27 hp-=power;
16266
16267
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 6 times.
27 if(hp>0)
16268 {
16269 21 misc=1;
16270 21 Stunclk=64;
16271 21 }
16272 else
16273 {
16274 6 loadpalset(csBOSS,pSprite(spBROWN));
16275 6 misc=2;
16276 6 Stunclk=284;
16277 6 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
16278 }
16279
16280 27 sfx(WAV_EHIT,pan(int32_t(x)));
16281
16282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
16283
16284 27 return 1;
16285
16286 case 2:
16287
4/6
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
71 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
16288 65 return 0;
16289
16290 6 misc=3;
16291 6 hclk=81;
16292 6 loadpalset(9,pSprite(spBROWN));
16293 6 return 1;
16294 }
16295
16296 426 return 0;
16297 524 }
16298
16299 10747 void eGanon::draw(BITMAP *dest)
16300 {
16301
6/6
✓ Branch 0 taken 1836 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 410 times.
✓ Branch 3 taken 1170 times.
✓ Branch 4 taken 6847 times.
✓ Branch 5 taken 480 times.
10747 switch(misc)
16302 {
16303 case 0:
16304
2/2
✓ Branch 0 taken 5135 times.
✓ Branch 1 taken 1712 times.
6847 if((clk&3)==3)
16305 1712 tile=(zc_oldrand()%5)*2+o_tile;
16306
16307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6847 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
16308 {
16309
16310 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16311 {
16312 int odraw = drawstyle;
16313 drawstyle = 2;
16314 drawblock(dest,15);
16315 drawstyle = odraw;
16316 }
16317 else
16318 {
16319 drawblock(dest,15);
16320 }
16321 break;
16322
16323 }
16324
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6847 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6847 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
16325 {
16326 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
16327 {
16328 int odraw = drawstyle;
16329 drawstyle = 2;
16330 drawblock(dest,15);
16331 drawstyle = odraw;
16332 }
16333 else
16334 {
16335 drawblock(dest,15);
16336 }
16337 break;
16338 }
16339
1/2
✓ Branch 0 taken 6847 times.
✗ Branch 1 not taken.
6847 if(db!=999)
16340 6847 break;
16341 [[fallthrough]];
16342 case 2:
16343
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
410 if(Stunclk<64 && (Stunclk&1))
16344 break;
16345 [[fallthrough]];
16346 case -1:
16347 1580 tile=o_tile;
16348
16349 [[fallthrough]];
16350 case 1:
16351 case 3:
16352 3416 drawblock(dest,15);
16353 3416 break;
16354
16355 case 4:
16356 480 draw_guts(dest);
16357 480 draw_flash(dest);
16358 480 break;
16359 }
16360 10747 }
16361
16362 480 void eGanon::draw_guts(BITMAP *dest)
16363 {
16364
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 102 times.
480 int32_t c = zc_min(clk>>3,8);
16365 480 tile = clk<24 ? 74 : 75;
16366 480 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
16367 480 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
16368 480 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
16369 480 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
16370 480 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
16371 480 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
16372 480 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
16373 480 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
16374 480 }
16375
16376 480 void eGanon::draw_flash(BITMAP *dest)
16377 {
16378
16379 480 int32_t c = clk-(clk>>2);
16380 480 cs = (frame&3)+6;
16381 480 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
16382 480 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
16383 480 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
16384 480 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
16385 480 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
16386 480 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
16387 480 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
16388 480 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
16389 480 }
16390
16391 6 void getBigTri(int32_t id2)
16392 {
16393 /*
16394 *************************
16395 * BIG TRIFORCE SEQUENCE *
16396 *************************
16397 0 BIGTRI out, WHITE flash in
16398 4 WHITE flash out, PILE cset white
16399 8 WHITE in
16400 ...
16401 188 WHITE out
16402 191 PILE cset red
16403 200 top SHUTTER opens
16404 209 bottom SHUTTER opens
16405 */
16406 6 sfx(itemsbuf[id2].playsound);
16407 6 guys.clear();
16408
16409
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
16410 {
16411 game->lvlitems[dlevel]|=liTRIFORCE;
16412 }
16413
16414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
16415
16416 6 draw_screen(tmpscr);
16417
16418
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1152 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 1152 times.
1158 for(int32_t f=0; f<24*8 && !Quit; f++)
16419 {
16420
2/2
✓ Branch 0 taken 1146 times.
✓ Branch 1 taken 6 times.
1152 if(f==4)
16421 {
16422
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 6 times.
96 for(int32_t i=1; i<16; i++)
16423 {
16424 90 RAMpal[CSET(9)+i]=_RGB(63,63,63);
16425 90 }
16426 6 }
16427
16428
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 144 times.
1152 if((f&7)==0)
16429 {
16430
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 144 times.
576 for(int32_t cs=2; cs<5; cs++)
16431 {
16432
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 432 times.
6912 for(int32_t i=1; i<16; i++)
16433 {
16434 6480 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
16435 6480 }
16436 432 }
16437
16438 144 refreshpal=true;
16439 144 }
16440
16441
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 144 times.
1152 if((f&7)==4)
16442 {
16443
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
16444 else loadlvlpal(0xB);
16445 144 }
16446
16447
2/2
✓ Branch 0 taken 1146 times.
✓ Branch 1 taken 6 times.
1152 if(f==191)
16448 {
16449 6 loadpalset(9,pSprite(spPILE));
16450 6 }
16451
16452 1152 advanceframe(true);
16453 1152 }
16454
16455 //play_DmapMusic();
16456 6 playLevelMusic();
16457
16458
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
16459 {
16460 Hero.dowarp(1,0); //side warp
16461 }
16462 6 }
16463
16464 /**********************************/
16465 /*** Multiple-Segment Enemies ***/
16466 /**********************************/
16467
16468
16469 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
16470 156 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16471 156 {
16472
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if( !(editorflags & ENEMY_FLAG5) )
16473 {
16474
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 x=128;
16475
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 y=48;
16476 78 }
16477 //else { x = X; y = Y; }
16478
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 dir=(zc_oldrand()&7)+8;
16479 78 superman=1;
16480 78 fading=fade_invisible;
16481 78 hxofs=1000;
16482 78 segcnt=clk;
16483 78 segid=Id|0x1000;
16484 78 clk=0;
16485
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 id=guys.Count();
16486
3/6
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
78 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16487 78 tile=o_tile;
16488 78 hitdir = -1;
16489 78 stickclk = 0;
16490
16491 /*
16492 if (get_bit(quest_rules,qr_NEWENEMYTILES))
16493 {
16494 tile=nets+1220;
16495 }
16496 else
16497 {
16498 tile=57;
16499 }
16500 */
16501 78 }
16502
16503 75195 bool eMoldorm::animate(int32_t index)
16504 {
16505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75195 times.
75195 if(switch_hooked) return enemy::animate(index);
16506 75195 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
16507
2/2
✓ Branch 0 taken 58230 times.
✓ Branch 1 taken 16965 times.
75195 if ( y > (max_y) )
16508 {
16509 16965 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
16510 //Z_scripterrlog("Stickclk is %d\n", stickclk);
16511 16965 }
16512
2/2
✓ Branch 0 taken 74846 times.
✓ Branch 1 taken 349 times.
75195 if ( stickclk > 45 )
16513 {
16514 349 stickclk = 0;
16515 349 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
16516 349 }
16517
16518
16519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75195 times.
75195 if(clk==0)
16520 {
16521 75195 removearmos(x,y,ffcactivated);
16522 75195 }
16523
16524
2/2
✓ Branch 0 taken 950 times.
✓ Branch 1 taken 74245 times.
75195 if(clk2)
16525 {
16526
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 50 times.
950 if(--clk2 == 0)
16527 {
16528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
50 if(flags&guy_neverret)
16529 50 never_return(index);
16530
16531
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
50 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
16532 50 leave_item();
16533
16534 50 stop_bgsfx(index);
16535 50 return true;
16536 }
16537 900 }
16538 else
16539 {
16540
1/2
✓ Branch 0 taken 74245 times.
✗ Branch 1 not taken.
74245 if(stunclk>0)
16541 stunclk=0;
16542 74245 constant_walk_8_old(rate,homing,spw_floater);
16543
16544
16545 74245 misc=dir;
16546
16547 // If any higher-numbered segments were killed, segcnt can be too high,
16548 // leading to a crash
16549
1/2
✓ Branch 0 taken 74245 times.
✗ Branch 1 not taken.
74245 if(index+segcnt>=guys.Count())
16550 segcnt=guys.Count()-index-1;
16551
16552
2/2
✓ Branch 0 taken 74245 times.
✓ Branch 1 taken 415023 times.
489268 for(int32_t i=index+1; i<index+segcnt+1; i++)
16553 {
16554 415023 enemy* segment=((enemy*)guys.spr(i));
16555
16556 // More validation - if segcnt was wrong, this may not
16557 // actually be a Moldorm segment
16558
1/2
✓ Branch 0 taken 415023 times.
✗ Branch 1 not taken.
415023 if(segment->id!=segid)
16559 {
16560 segcnt=i-index-1;
16561 break;
16562 }
16563
16564
2/2
✓ Branch 0 taken 340711 times.
✓ Branch 1 taken 74312 times.
415023 if(i==index+1)
16565 {
16566 74312 x=segment->x;
16567 74312 y=segment->y;
16568 74312 }
16569
16570 415023 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
16571 //Script your own blasted segmented bosses!! -Z
16572 415023 segment->parent_script_UID = this->script_UID;
16573
4/4
✓ Branch 0 taken 74245 times.
✓ Branch 1 taken 340778 times.
✓ Branch 2 taken 10161 times.
✓ Branch 3 taken 64084 times.
415023 if((i==index+segcnt)&&(i!=index+1)) //tail
16574 {
16575 64084 segment->dummy_int[1]=2;
16576 64084 }
16577 else
16578 {
16579 350939 segment->dummy_int[1]=1;
16580 }
16581
16582
2/2
✓ Branch 0 taken 340711 times.
✓ Branch 1 taken 74312 times.
415023 if(i==index+1) //head
16583 {
16584 74312 segment->dummy_int[1]=0;
16585 74312 }
16586
16587
2/2
✓ Branch 0 taken 414703 times.
✓ Branch 1 taken 320 times.
415023 if(segment->hp <= 0)
16588 {
16589 320 int32_t offset=1;
16590
16591
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 532 times.
852 for(int32_t j=i; j<index+segcnt; j++)
16592 {
16593 // Triple-check
16594
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(((enemy*)guys.spr(j+1))->id!=segid)
16595 {
16596 segcnt=j-index+1; // Add 1 because of --segcnt below
16597 break;
16598 }
16599 532 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16600 532 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16601 532 }
16602
16603 320 segment->hclk=33;
16604 320 --segcnt;
16605 320 --i; // Recheck the same index in case multiple segments died at once
16606 320 }
16607 415023 }
16608
16609
2/2
✓ Branch 0 taken 74195 times.
✓ Branch 1 taken 50 times.
74245 if(segcnt==0)
16610 {
16611 50 clk2=19;
16612
16613 50 x=guys.spr(index+1)->x;
16614 50 y=guys.spr(index+1)->y;
16615 50 }
16616 }
16617
16618 75145 return false;
16619 75195 }
16620
16621 900 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
16622 900 {
16623
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 if( !(editorflags & ENEMY_FLAG5) )
16624 {
16625
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 x=128;
16626
1/2
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
450 y=48;
16627 450 }
16628
16629
3/6
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 450 times.
✓ Branch 4 taken 450 times.
✗ Branch 5 not taken.
450 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16630 450 hyofs=4;
16631 450 hxsz=hysz=8;
16632 450 hxofs=1000;
16633 450 mainguy=count_enemy=false;
16634 450 parentclk = 0;
16635 450 bgsfx=-1;
16636 450 flags&=~guy_neverret;
16637 //deadsfx = WAV_EDEAD;
16638 450 isCore = false;
16639 450 }
16640
16641 420783 bool esMoldorm::animate(int32_t index)
16642 {
16643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 420783 times.
420783 if(switch_hooked) return enemy::animate(index);
16644 // Shouldn't be possible, but better to be sure
16645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 420783 times.
420783 if(index==0)
16646 dying=true;
16647
16648
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 415023 times.
420783 if(dying)
16649 {
16650
1/2
✓ Branch 0 taken 5760 times.
✗ Branch 1 not taken.
5760 if(!dmisc2)
16651 5760 item_set=0;
16652
16653 5760 return Dead(index);
16654 }
16655
16656
2/2
✓ Branch 0 taken 19478 times.
✓ Branch 1 taken 395545 times.
415023 if(clk>=0)
16657 {
16658 395545 hxofs=4;
16659 395545 step=((enemy*)guys.spr(index-1))->step;
16660
16661
2/2
✓ Branch 0 taken 30349 times.
✓ Branch 1 taken 365196 times.
395545 if(parentclk == 0)
16662 {
16663 30349 misc=dir;
16664 30349 dir=((enemy*)guys.spr(index-1))->misc;
16665 //do alignment, as in parent's animation :-/ -DD
16666 30349 x.doFloor();
16667 30349 y.doFloor();
16668 30349 }
16669
16670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395545 times.
395545 if(step)
16671 395545 parentclk=(parentclk+1)%((int32_t)(8.0/step));
16672
16673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 395545 times.
395545 if(!watch)
16674 {
16675 395545 sprite::move(step);
16676 395545 }
16677 395545 }
16678
16679 415023 return enemy::animate(index);
16680 420783 }
16681
16682 1599 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
16683 {
16684
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 147 times.
1599 if(enemy::takehit(w,realweap))
16685 1452 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
16686
16687 147 return 0;
16688 1599 }
16689
16690 422733 void esMoldorm::draw(BITMAP *dest)
16691 {
16692 422733 tile=o_tile;
16693 422733 int32_t fdiv = frate/4;
16694
1/2
✓ Branch 0 taken 422733 times.
✗ Branch 1 not taken.
422733 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
16695
16696
2/2
✓ Branch 0 taken 361156 times.
✓ Branch 1 taken 61577 times.
422733 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
16697 422733 efrate:((clk>=(frate>>1))?1:0);
16698
16699
2/2
✓ Branch 0 taken 61577 times.
✓ Branch 1 taken 361156 times.
422733 if(get_bit(quest_rules,qr_NEWENEMYTILES))
16700 {
16701 361156 tile+=dummy_int[1]*40;
16702
16703
2/2
✓ Branch 0 taken 16310 times.
✓ Branch 1 taken 344846 times.
361156 if(dir<8)
16704 {
16705 16310 flip=0;
16706
2/2
✓ Branch 0 taken 12412 times.
✓ Branch 1 taken 3898 times.
16310 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
16707
16708
1/2
✓ Branch 0 taken 16310 times.
✗ Branch 1 not taken.
16310 if(dir>3) // Skip to the next row for diagonals
16709 tile+=4;
16710 16310 }
16711 else
16712 {
16713
8/9
✓ Branch 0 taken 37639 times.
✓ Branch 1 taken 47584 times.
✓ Branch 2 taken 38450 times.
✓ Branch 3 taken 47147 times.
✓ Branch 4 taken 39397 times.
✓ Branch 5 taken 38189 times.
✓ Branch 6 taken 46292 times.
✓ Branch 7 taken 50148 times.
✗ Branch 8 not taken.
344846 switch(dir-8) //directions get screwed up after 8. *shrug*
16714 {
16715 case up: //u
16716 37639 flip=0;
16717 37639 break;
16718
16719 case l_up: //d
16720 47584 flip=0;
16721 47584 tile+=4;
16722 47584 break;
16723
16724 case l_down: //l
16725 38450 flip=0;
16726 38450 tile+=8;
16727 38450 break;
16728
16729 case left: //r
16730 47147 flip=0;
16731 47147 tile+=12;
16732 47147 break;
16733
16734 case r_down: //ul
16735 39397 flip=0;
16736 39397 tile+=20;
16737 39397 break;
16738
16739 case down: //ur
16740 38189 flip=0;
16741 38189 tile+=24;
16742 38189 break;
16743
16744 case r_up: //dl
16745 46292 flip=0;
16746 46292 tile+=28;
16747 46292 break;
16748
16749 case right: //dr
16750 50148 flip=0;
16751 50148 tile+=32;
16752 50148 break;
16753 }
16754 }
16755
16756 361156 tile+=f2;
16757 361156 }
16758
16759
2/2
✓ Branch 0 taken 19532 times.
✓ Branch 1 taken 403201 times.
422733 if(clk>=0)
16760 403201 enemy::draw(dest);
16761 422733 }
16762
16763 180 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16764 180 {
16765
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if( !(editorflags & ENEMY_FLAG5) )
16766 {
16767
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 x=64;
16768
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 y=80;
16769 90 }
16770 //else { x = X; y = Y; }
16771 //zprint2("lanmola index is %d\n", index);
16772 //byte legaldirs = 0;
16773 90 int32_t incr = 16;
16774 //int32_t possiiblepos = 0;
16775 //int32_t positions[8] = {0};
16776
16777 //Don't spawn in pits.
16778
5/8
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✓ Branch 7 taken 2 times.
90 if ( m_walkflag_simple(x, y) )
16779 {
16780 //zprint2("Can't spawn here.\n");
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 for ( ; incr < 240; incr += 16 )
16782 {
16783 //move if we spawn over a pit
16784 //check each direction
16785
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16786 {
16787 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16788
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 x-=incr; break;
16789 }
16790 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16791 {
16792 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16793 x+=incr; break;
16794 }
16795 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16796 {
16797 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16798 x-=incr; y-=incr; break;
16799 }
16800 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16801 {
16802 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16803 x+=incr; y-=incr; break;
16804 }
16805 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
16806 {
16807 //zprint2("Spawn adjustment: -y (%d)\n", incr);
16808 y -= incr; break;
16809 }
16810 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
16811 {
16812 //zprint2("Spawn adjustment: +y (%d)\n", incr);
16813 y+=incr; break;
16814 }
16815 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
16816 {
16817 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
16818 x-=incr; y+=incr; break;
16819 }
16820 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
16821 {
16822 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
16823 x+=incr; y+=incr; break;
16824 }
16825 else continue;
16826
16827 }
16828
16829 2 }
16830
16831 90 dir=up;
16832 90 superman=1;
16833 90 fading=fade_invisible;
16834 90 hxofs=1000;
16835 90 segcnt=clk;
16836 90 clk=0;
16837 //set up move history
16838
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 778 times.
868 for(int32_t i=0; i <= (1<<dmisc2); i++)
16839
3/6
✓ Branch 0 taken 778 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 778 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 778 times.
✗ Branch 5 not taken.
778 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
16840 90 }
16841
16842 87883 bool eLanmola::animate(int32_t index)
16843 {
16844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87883 times.
87883 if(switch_hooked) return enemy::animate(index);
16845
2/2
✓ Branch 0 taken 75385 times.
✓ Branch 1 taken 12498 times.
87883 if(clk==0)
16846 {
16847 12498 removearmos(x,y,ffcactivated);
16848 12498 }
16849
16850
2/2
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 86420 times.
87883 if(clk2)
16851 {
16852
2/2
✓ Branch 0 taken 1386 times.
✓ Branch 1 taken 77 times.
1463 if(--clk2 == 0)
16853 {
16854
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 20 times.
77 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
16855 57 leave_item();
16856
16857 77 stop_bgsfx(index);
16858 77 return true;
16859 }
16860
16861 1386 return false;
16862 }
16863
16864
16865 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
16866 //the direction AND x,y position of the lanmola to vary in uncertain ways.
16867 //I've added a complete movement history to this enemy to compensate -DD
16868 86420 constant_walk(rate,homing,spw_none);
16869 86420 prevState.pop_front();
16870 86420 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
16871
16872 // This could cause a crash with Moldorms. I didn't see the same problem
16873 // with Lanmolas, but it looks like it ought to be possible, so here's
16874 // the same solution. - Saf
16875
1/2
✓ Branch 0 taken 86420 times.
✗ Branch 1 not taken.
86420 if(index+segcnt>=guys.Count())
16876 segcnt=guys.Count()-index-1;
16877
16878
2/2
✓ Branch 0 taken 86420 times.
✓ Branch 1 taken 401833 times.
488253 for(int32_t i=index+1; i<index+segcnt+1; i++)
16879 {
16880 401833 enemy* segment=((enemy*)guys.spr(i));
16881
16882 // More validation in case segcnt is wrong
16883
1/2
✓ Branch 0 taken 401833 times.
✗ Branch 1 not taken.
401833 if((segment->id&0xFFF)!=(id&0xFFF))
16884 {
16885 segcnt=i-index-1;
16886 break;
16887 }
16888
16889 401833 segment->o_tile=o_tile;
16890 401833 segment->parent_script_UID = this->script_UID;
16891
4/4
✓ Branch 0 taken 86420 times.
✓ Branch 1 taken 315413 times.
✓ Branch 2 taken 16001 times.
✓ Branch 3 taken 70419 times.
401833 if((i==index+segcnt)&&(i!=index+1))
16892 {
16893 70419 segment->dummy_int[1]=1; //tail
16894 70419 }
16895 else
16896 {
16897 331414 segment->dummy_int[1]=0;
16898 }
16899
16900
2/2
✓ Branch 0 taken 401382 times.
✓ Branch 1 taken 451 times.
401833 if(segment->hp <= 0)
16901 {
16902
2/2
✓ Branch 0 taken 451 times.
✓ Branch 1 taken 811 times.
1262 for(int32_t j=i; j<index+segcnt; j++)
16903 {
16904 // Triple-check
16905
1/2
✓ Branch 0 taken 811 times.
✗ Branch 1 not taken.
811 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
16906 {
16907 segcnt=j-index+1; // Add 1 because of --segcnt below
16908 break;
16909 }
16910 811 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
16911 811 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
16912 811 }
16913
16914 451 ((enemy*)guys.spr(i))->hclk=33;
16915 451 --segcnt;
16916 451 --i; // Recheck the same index in case multiple segments died at once
16917 451 }
16918 401833 }
16919
16920
2/2
✓ Branch 0 taken 86343 times.
✓ Branch 1 taken 77 times.
86420 if(segcnt==0)
16921 {
16922 77 clk2=19;
16923 77 x=guys.spr(index+1)->x;
16924 77 y=guys.spr(index+1)->y;
16925 77 setmapflag(mTMPNORET);
16926 77 }
16927
16928 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
16929 //which is... disastrous.
16930 86420 hp = 1;
16931 86420 return enemy::animate(index);
16932 87883 }
16933
16934 1010 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
16935 1010 {
16936
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 if( !(editorflags & ENEMY_FLAG5) )
16937 {
16938
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 x=64;
16939
1/2
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
505 y=80;
16940 505 }
16941 505 int32_t incr = 16;
16942 //Don't spawn in pits.
16943
5/8
✓ Branch 0 taken 505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 505 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 505 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 495 times.
✓ Branch 7 taken 10 times.
505 if ( m_walkflag_simple(x, y) )
16944 {
16945 //zprint2("Can't spawn here.\n");
16946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 for ( ; incr < 240; incr += 16 )
16947 {
16948 //move if we spawn over a pit
16949 //check each direction
16950
6/12
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10 times.
✗ Branch 11 not taken.
10 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
16951 {
16952 //zprint2("Spawn adjustment: -x (%d)\n", incr);
16953
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 x-=incr; break;
16954 }
16955 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
16956 {
16957 //zprint2("Spawn adjustment: +x (%d)\n", incr);
16958 x+=incr; break;
16959 }
16960 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
16961 {
16962 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
16963 x-=incr; y-=incr; break;
16964 }
16965 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
16966 {
16967 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
16968 x+=incr; y-=incr; break;
16969 }
16970 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
16971 {
16972 //zprint2("Spawn adjustment: -y (%d)\n", incr);
16973 y -= incr; break;
16974 }
16975 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
16976 {
16977 //zprint2("Spawn adjustment: +y (%d)\n", incr);
16978 y+=incr; break;
16979 }
16980 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
16981 {
16982 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
16983 x-=incr; y+=incr; break;
16984 }
16985 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
16986 {
16987 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
16988 x+=incr; y+=incr; break;
16989 }
16990 else continue;
16991
16992 }
16993
16994 10 }
16995
16996 505 hxofs=1000;
16997 505 hxsz=8;
16998 505 mainguy=false;
16999 505 count_enemy=(id<0x2000)?true:false;
17000
17001 //set up move history
17002
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 4345 times.
4850 for(int32_t i=0; i <= (1<<dmisc2); i++)
17003
3/6
✓ Branch 0 taken 4345 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4345 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4345 times.
✗ Branch 5 not taken.
4345 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
17004
17005 505 bgsfx = -1;
17006 505 isCore = false;
17007 505 flags&=~guy_neverret;
17008 505 }
17009
17010 409951 bool esLanmola::animate(int32_t index)
17011 {
17012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409951 times.
409951 if(switch_hooked) return enemy::animate(index);
17013 // Shouldn't be possible, but who knows
17014
1/2
✓ Branch 0 taken 409951 times.
✗ Branch 1 not taken.
409951 if(index==0)
17015 dying=true;
17016
17017
2/2
✓ Branch 0 taken 8118 times.
✓ Branch 1 taken 401833 times.
409951 if(dying)
17018 {
17019 8118 xofs=0;
17020
17021
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 6318 times.
8118 if(!dmisc3)
17022 6318 item_set=0;
17023
17024 8118 return Dead(index);
17025 }
17026
17027
2/2
✓ Branch 0 taken 11680 times.
✓ Branch 1 taken 390153 times.
401833 if(clk>=0)
17028 {
17029 390153 hxofs=4;
17030
17031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390153 times.
390153 if(!watch)
17032 {
17033 390153 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
17034 390153 prevState.pop_front();
17035 390153 prevState.push_back(newstate);
17036 390153 x = newstate.first.first;
17037 390153 y = newstate.first.second;
17038 390153 dir = newstate.second;
17039 390153 }
17040 390153 }
17041
17042 401833 return enemy::animate(index);
17043 409951 }
17044
17045 1324 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
17046 {
17047
2/2
✓ Branch 0 taken 1208 times.
✓ Branch 1 taken 116 times.
1324 if(enemy::takehit(w,realweap))
17048 1208 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
17049
17050 116 return 0;
17051 1324 }
17052
17053 411232 void esLanmola::draw(BITMAP *dest)
17054 {
17055 411232 tile=o_tile;
17056 411232 int32_t fdiv = frate/4;
17057
1/2
✓ Branch 0 taken 411232 times.
✗ Branch 1 not taken.
411232 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17058
17059
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 73699 times.
411232 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17060 411232 efrate:((clk>=(frate>>1))?1:0);
17061
17062
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 73699 times.
411232 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17063 {
17064
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
17065 {
17066 269264 tile+=20;
17067
17068
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
17069 {
17070 59482 tile+=20;
17071 59482 }
17072 269264 }
17073
17074
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
17075 {
17076 case up:
17077 70158 flip=0;
17078 70158 break;
17079
17080 case down:
17081 71956 flip=0;
17082 71956 tile+=4;
17083 71956 break;
17084
17085 case left:
17086 93557 flip=0;
17087 93557 tile+=8;
17088 93557 break;
17089
17090 case right:
17091 101862 flip=0;
17092 101862 tile+=12;
17093 101862 break;
17094 }
17095
17096 337533 tile+=f2;
17097 337533 }
17098 else
17099 {
17100
2/2
✓ Branch 0 taken 20051 times.
✓ Branch 1 taken 53648 times.
73699 if(id>=0x2000)
17101 {
17102 53648 tile+=1;
17103 53648 }
17104 }
17105
17106
2/2
✓ Branch 0 taken 11680 times.
✓ Branch 1 taken 399552 times.
411232 if(clk>=0)
17107 399552 enemy::draw(dest);
17108 411232 }
17109
17110 108 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
17111 108 {
17112 //these are here to bypass compiler warnings about unused arguments
17113 54 Clk=Clk;
17114 54 superman=1;
17115
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 dir=(zc_oldrand()&7)+8;
17116 54 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
17117
17118
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 54 times.
302 for(int32_t i=0; i<armcnt; i++)
17119 248 arm[i]=i;
17120
17121 54 fading=fade_blue_poof;
17122 //nets+4680;
17123 54 adjusted=false;
17124 54 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
17125
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17126 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17127 // al_trace("Enemy txsz:%i\n", txsz);
17128
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17131
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17132
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17133
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17134 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17137 {
17138 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17139 }
17140
17141
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17142 54 }
17143
17144 28824 bool eManhandla::animate(int32_t index)
17145 {
17146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28824 times.
28824 if(switch_hooked) return enemy::animate(index);
17147
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 28122 times.
28824 if(dying)
17148 702 return Dead(index);
17149
17150
2/2
✓ Branch 0 taken 26926 times.
✓ Branch 1 taken 1196 times.
28122 if(clk==0)
17151 {
17152 1196 removearmos(x,y,ffcactivated);
17153 1196 }
17154
17155
17156 // check arm status, move dead ones to end of group
17157
2/2
✓ Branch 0 taken 88458 times.
✓ Branch 1 taken 28122 times.
116580 for(int32_t i=0; i<armcnt; i++)
17158 {
17159 88458 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
17160
3/4
✓ Branch 0 taken 88458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 188 times.
✓ Branch 3 taken 88270 times.
88458 if(!cur_arm || cur_arm->dying)
17161 {
17162
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 188 times.
423 for(int32_t j=i; j<armcnt-1; j++)
17163 {
17164 235 zc_swap(arm[j],arm[j+1]);
17165 235 guys.swap(index+j+1,index+j+2);
17166 235 }
17167
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 20 times.
188 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
17168 {
17169 20 leave_item();
17170 20 }
17171 188 --armcnt;
17172 188 --i;
17173 188 continue;
17174 }
17175
2/2
✓ Branch 0 taken 88022 times.
✓ Branch 1 taken 248 times.
88270 if(!adjusted)
17176 {
17177
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 64 times.
248 if(!dmisc2)
17178 {
17179 184 cur_arm->o_tile=o_tile+40;
17180 184 cur_arm->parent_script_UID = this->script_UID;
17181 184 }
17182 else
17183 {
17184 64 cur_arm->o_tile=o_tile+160;
17185 64 cur_arm->parent_script_UID = this->script_UID;
17186 }
17187 248 }
17188 88270 }
17189
17190 28122 adjusted=true;
17191
17192 // move or die
17193
2/2
✓ Branch 0 taken 28083 times.
✓ Branch 1 taken 39 times.
28122 if(armcnt==0)
17194 39 hp=0;
17195 else
17196 {
17197 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
17198
1/2
✓ Branch 0 taken 28083 times.
✗ Branch 1 not taken.
28083 step=zc_min(zfix(4.5),(((!dmisc2)?4:8)-int64_t(armcnt))*0.5+zslongToFix(dstep*100));
17199 28083 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
17200
17201
2/2
✓ Branch 0 taken 25202 times.
✓ Branch 1 taken 2881 times.
28083 if(!dmisc2)
17202 {
17203
2/2
✓ Branch 0 taken 74283 times.
✓ Branch 1 taken 25202 times.
99485 for(int32_t i=0; i<armcnt; i++)
17204 {
17205
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17558 times.
✓ Branch 2 taken 19867 times.
✓ Branch 3 taken 18200 times.
✓ Branch 4 taken 18658 times.
74283 switch(arm[i])
17206 {
17207 case 0:
17208 17558 dy1=-24;
17209 17558 break;
17210
17211 case 1:
17212 19867 dy2=31;
17213 19867 break;
17214
17215 case 2:
17216 18200 dx1=-16;
17217 18200 break;
17218
17219 case 3:
17220 18658 dx2=31;
17221 18658 break;
17222 }
17223 74283 }
17224 25202 }
17225 else
17226 {
17227 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
17228
17229
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
17230 {
17231
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
17232 {
17233 case 0:
17234 4279 dy1=-32;
17235 4279 break;
17236
17237 case 1:
17238 3184 dy2=39;
17239 3184 break;
17240
17241 case 2:
17242 2549 dx1=-24;
17243 2549 break;
17244
17245 case 3:
17246 3975 dx2=39;
17247 3975 break;
17248 }
17249 13987 }
17250 }
17251
17252 28083 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
17253
17254
2/2
✓ Branch 0 taken 88270 times.
✓ Branch 1 taken 28083 times.
116353 for(int32_t i=0; i<armcnt; i++)
17255 {
17256 88270 zfix dx=(zfix)0,dy=(zfix)0;
17257
17258
2/2
✓ Branch 0 taken 74283 times.
✓ Branch 1 taken 13987 times.
88270 if(!dmisc2)
17259 {
17260
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17558 times.
✓ Branch 2 taken 19867 times.
✓ Branch 3 taken 18200 times.
✓ Branch 4 taken 18658 times.
74283 switch(arm[i])
17261 {
17262 case 0:
17263 17558 dy=-16;
17264 17558 break;
17265
17266 case 1:
17267 19867 dy=16;
17268 19867 break;
17269
17270 case 2:
17271 18200 dx=-16;
17272 18200 break;
17273
17274 case 3:
17275 18658 dx=16;
17276 18658 break;
17277 }
17278 74283 }
17279 else
17280 {
17281
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
17282 {
17283 case 0:
17284 1680 dy=-24;
17285 1680 dx=-8;
17286 1680 break;
17287
17288 case 1:
17289 1789 dy=24;
17290 1789 dx=8;
17291 1789 break;
17292
17293 case 2:
17294 1292 dx=-24;
17295 1292 dy=8;
17296 1292 break;
17297
17298 case 3:
17299 2015 dx=24;
17300 2015 dy=-8;
17301 2015 break;
17302
17303 case 4:
17304 2599 dy=-24;
17305 2599 dx=8;
17306 2599 break;
17307
17308 case 5:
17309 1395 dy=24;
17310 1395 dx=-8;
17311 1395 break;
17312
17313 case 6:
17314 1257 dx=-24;
17315 1257 dy=-8;
17316 1257 break;
17317
17318 case 7:
17319 1960 dx=24;
17320 1960 dy=8;
17321 1960 break;
17322 }
17323 }
17324
17325 88270 guys.spr(index+i+1)->x = x+dx;
17326 88270 guys.spr(index+i+1)->y = y+dy;
17327 88270 }
17328 }
17329
17330 28122 return enemy::animate(index);
17331 28824 }
17332
17333
17334 1232 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
17335 {
17336 1232 int32_t wpnId = w->id;
17337
17338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1232 times.
1232 if(dying)
17339 return 0;
17340
17341
3/4
✓ Branch 0 taken 799 times.
✓ Branch 1 taken 417 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
1232 switch(wpnId)
17342 {
17343 case wBomb:
17344 case wSBomb:
17345 case wSword:
17346 case wHammer:
17347 case wWand:
17348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 417 times.
417 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17349
17350 case wLitBomb:
17351 case wLitSBomb:
17352 case wBait:
17353 case wWhistle:
17354 case wFire:
17355 case wWind:
17356 case wSSparkle:
17357 case wFSparkle:
17358 case wPhantom:
17359 1216 return 0;
17360
17361 case wHookshot:
17362 case wBrang:
17363 sfx(WAV_CHINK,pan(int32_t(x)));
17364 break;
17365
17366 default:
17367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (get_bit(quest_rules, qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
17368 else sfx(WAV_CHINK,pan(int32_t(x)));
17369
17370 16 }
17371
17372 16 return 1;
17373 1232 }
17374
17375 28822 void eManhandla::draw(BITMAP *dest)
17376 {
17377 28822 tile=o_tile;
17378 28822 int32_t fdiv = frate/4;
17379
1/2
✓ Branch 0 taken 28822 times.
✗ Branch 1 not taken.
28822 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17380
17381
2/2
✓ Branch 0 taken 21250 times.
✓ Branch 1 taken 7572 times.
28822 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17382 28822 efrate:((clk>=(frate>>1))?1:0);
17383
17384
2/2
✓ Branch 0 taken 21250 times.
✓ Branch 1 taken 7572 times.
28822 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17385 {
17386
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 18732 times.
21250 if(!dmisc2)
17387 {
17388
8/9
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 2084 times.
✓ Branch 2 taken 2751 times.
✓ Branch 3 taken 2878 times.
✓ Branch 4 taken 1783 times.
✓ Branch 5 taken 1846 times.
✓ Branch 6 taken 1929 times.
✓ Branch 7 taken 3061 times.
✗ Branch 8 not taken.
18732 switch(dir-8) //directions get screwed up after 8. *shrug*
17389 {
17390 case up: //u
17391 2400 flip=0;
17392 2400 break;
17393
17394 case l_up: //d
17395 2084 flip=0;
17396 2084 tile+=4;
17397 2084 break;
17398
17399 case l_down: //l
17400 2751 flip=0;
17401 2751 tile+=8;
17402 2751 break;
17403
17404 case left: //r
17405 2878 flip=0;
17406 2878 tile+=12;
17407 2878 break;
17408
17409 case r_down: //ul
17410 1783 flip=0;
17411 1783 tile+=20;
17412 1783 break;
17413
17414 case down: //ur
17415 1846 flip=0;
17416 1846 tile+=24;
17417 1846 break;
17418
17419 case r_up: //dl
17420 1929 flip=0;
17421 1929 tile+=28;
17422 1929 break;
17423
17424 case right: //dr
17425 3061 flip=0;
17426 3061 tile+=32;
17427 3061 break;
17428 }
17429
17430 18732 tile+=f2;
17431 18732 enemy::draw(dest);
17432 18732 } //manhandla 2, big body
17433 else
17434 {
17435
17436
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
17437 {
17438 case up: //u
17439 357 flip=0;
17440 357 break;
17441
17442 case l_up: //d
17443 483 flip=0;
17444 483 tile+=8;
17445 483 break;
17446
17447 case l_down: //l
17448 500 flip=0;
17449 500 tile+=40;
17450 500 break;
17451
17452 case left: //r
17453 315 flip=0;
17454 315 tile+=48;
17455 315 break;
17456
17457 case r_down: //ul
17458 196 flip=0;
17459 196 tile+=80;
17460 196 break;
17461
17462 case down: //ur
17463 215 flip=0;
17464 215 tile+=88;
17465 215 break;
17466
17467 case r_up: //dl
17468 164 flip=0;
17469 164 tile+=120;
17470 164 break;
17471
17472 case right: //dr
17473 288 flip=0;
17474 288 tile+=128;
17475 288 break;
17476 }
17477
17478 2518 tile+=(f2*2);
17479 2518 xofs-=8;
17480 2518 yofs-=8;
17481 2518 drawblock(dest,15);
17482 2518 xofs+=8;
17483 2518 yofs+=8;
17484 }
17485 21250 }
17486 else
17487 {
17488
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 7057 times.
7572 if(!dmisc2)
17489 {
17490 7057 enemy::draw(dest);
17491 7057 }
17492 else
17493 {
17494 515 xofs-=8;
17495 515 yofs-=8;
17496 515 enemy::draw(dest);
17497 515 xofs+=16;
17498 515 enemy::draw(dest);
17499 515 yofs+=16;
17500 515 enemy::draw(dest);
17501 515 xofs-=16;
17502 515 enemy::draw(dest);
17503 515 xofs+=8;
17504 515 yofs-=8;
17505 }
17506 }
17507 28822 }
17508
17509 496 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
17510 496 {
17511 248 id=misc=clk;
17512 248 dir = clk & 3;
17513 248 clk=0;
17514 248 mainguy=count_enemy=false;
17515 248 dummy_bool[0]=false;
17516 248 item_set=0;
17517 248 bgsfx=-1;
17518 248 deadsfx = WAV_EDEAD;
17519 248 flags &= (~guy_neverret);
17520 248 isCore = false;
17521 //Probably will be buggy. -Z 12 AUG 2020
17522 248 SIZEflags = d->SIZEflags;
17523
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17524 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17525 // al_trace("Enemy txsz:%i\n", txsz);
17526
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17527
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
17528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
17529
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17530
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17531
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17532 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17533
1/4
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
17534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17535 {
17536 yofs = d->yofs+(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17537 }
17538
17539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
248 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
17540 248 }
17541
17542 91654 bool esManhandla::animate(int32_t index)
17543 {
17544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91654 times.
91654 if(switch_hooked) return enemy::animate(index);
17545
2/2
✓ Branch 0 taken 3384 times.
✓ Branch 1 taken 88270 times.
91654 if(dying)
17546 3384 return Dead(index);
17547
17548
2/2
✓ Branch 0 taken 5629 times.
✓ Branch 1 taken 82641 times.
88270 if(clk==0)
17549 {
17550 5629 removearmos(x,y,ffcactivated);
17551 5629 }
17552
17553
2/2
✓ Branch 0 taken 75539 times.
✓ Branch 1 taken 12731 times.
88270 if(--clk2<=0)
17554 {
17555 12731 clk2=unsigned(zc_oldrand())%5+5;
17556 12731 clk3^=1;
17557 12731 }
17558
17559
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 87572 times.
88270 if(!(zc_oldrand()&127))
17560 {
17561 698 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
17562 698 sfx(wpnsfx(wpn),pan(int32_t(x)));
17563 698 }
17564
17565 88270 return enemy::animate(index);
17566 91654 }
17567
17568 91646 void esManhandla::draw(BITMAP *dest)
17569 {
17570 91646 tile=o_tile;
17571 91646 int32_t fdiv = frate/4;
17572
1/2
✓ Branch 0 taken 91646 times.
✗ Branch 1 not taken.
91646 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
17573
2/2
✓ Branch 0 taken 70295 times.
✓ Branch 1 taken 21351 times.
91646 int32_t f2=get_bit(quest_rules,qr_NEWENEMYTILES)?
17574 91646 efrate:((clk>=(frate>>1))?1:0);
17575
17576
2/2
✓ Branch 0 taken 70295 times.
✓ Branch 1 taken 21351 times.
91646 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17577 {
17578
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16874 times.
✓ Branch 2 taken 18626 times.
✓ Branch 3 taken 17275 times.
✓ Branch 4 taken 17520 times.
70295 switch(misc&3)
17579 {
17580 case up:
17581 16874 break;
17582
17583 case down:
17584 18626 tile+=4;
17585 18626 break;
17586
17587 case left:
17588 17275 tile+=8;
17589 17275 break;
17590
17591 case right:
17592 17520 tile+=12;
17593 17520 break;
17594 }
17595
17596 70295 tile+=f2;
17597 70295 }
17598 else
17599 {
17600
4/5
✓ Branch 0 taken 5269 times.
✓ Branch 1 taken 5957 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5807 times.
✓ Branch 4 taken 4318 times.
21351 switch(misc&3)
17601 {
17602 case down:
17603 5269 flip=2;
17604
17605 [[fallthrough]];
17606 case up:
17607 11076 tile=(clk3)?188:189;
17608 11076 break;
17609
17610 case right:
17611 5957 flip=1;
17612 [[fallthrough]];
17613
17614 case left:
17615 10275 tile=(clk3)?186:187;
17616 10275 break;
17617 }
17618 }
17619
17620 91646 enemy::draw(dest);
17621 91646 }
17622
17623 158 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
17624 158 {
17625
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if ( !(editorflags & ENEMY_FLAG5) )
17626 {
17627
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 x = 120;
17628
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 y = 48;
17629 79 }
17630 else
17631 {
17632 if ( !(editorflags & ENEMY_FLAG6) )
17633 {
17634 x = X; y = Y;
17635 }
17636 else
17637 {
17638 x = X+8; y = Y;
17639 }
17640 }
17641 79 hzsz = 32; // can't be jumped.
17642 79 flameclk=0;
17643 79 misc=clk; // total head count
17644 79 clk3=clk; // live head count
17645 79 clk=0;
17646 79 clk2=60; // fire ball clock
17647 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
17648
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
17649 79 dir = down;
17650 79 hxofs=4;
17651 79 hxsz=8;
17652 // frate=17*4;
17653 79 fading=fade_blue_poof;
17654 //nets+5420;
17655
3/4
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 14 times.
79 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17656 {
17657 /*
17658 necktile=o_tile+8;
17659 if (dmisc3)
17660 {
17661 necktile+=8;
17662 }
17663 */
17664 65 necktile=o_tile+dmisc6;
17665 65 }
17666 else
17667 {
17668 14 necktile=s_tile;
17669 }
17670 79 }
17671
17672 60815 bool eGleeok::animate(int32_t index)
17673 {
17674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60815 times.
60815 if(switch_hooked) return enemy::animate(index);
17675
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 59753 times.
60815 if(dying)
17676 1062 return Dead(index);
17677
17678
2/2
✓ Branch 0 taken 59480 times.
✓ Branch 1 taken 273 times.
59753 if(clk==0)
17679 {
17680 273 removearmos(x,y,ffcactivated);
17681 273 }
17682
17683 // Check if a head was killed somehow...
17684
2/2
✓ Branch 0 taken 31194 times.
✓ Branch 1 taken 28559 times.
59753 if(index+1+clk3>=guys.Count())
17685 28559 clk3=guys.Count()-index-1;
17686
2/2
✓ Branch 0 taken 13105 times.
✓ Branch 1 taken 46648 times.
59753 if(index+1+misc>=guys.Count())
17687 46648 misc=guys.Count()-index-1;
17688
17689 //fix for the "kill all enemies" item
17690
2/2
✓ Branch 0 taken 59747 times.
✓ Branch 1 taken 6 times.
59753 if(hp==-1000)
17691 {
17692
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
17693 {
17694 // I haven't seen this fail, but it seems like it ought to be
17695 // possible, so I'm checking for it. - Saf
17696
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17697 break;
17698 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
17699 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
17700 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
17701 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
17702 12 }
17703
17704 6 clk3=0;
17705
17706
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
17707 {
17708
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
17709 break;
17710 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17711 12 }
17712 6 }
17713
17714
2/2
✓ Branch 0 taken 136077 times.
✓ Branch 1 taken 59753 times.
195830 for(int32_t i=0; i<clk3; i++)
17715 {
17716 136077 enemy *head = ((enemy*)guys.spr(index+i+1));
17717 136077 head->dummy_int[1]=necktile;
17718 136077 head->parent_script_UID = this->script_UID;
17719
17720
2/2
✓ Branch 0 taken 98803 times.
✓ Branch 1 taken 37274 times.
136077 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17721 {
17722 98803 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
17723 98803 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
17724 98803 }
17725 else
17726 {
17727 37274 head->dummy_int[2]=necktile+1; //connected head tile
17728 37274 head->dummy_int[3]=necktile+2; //flying head tile
17729 }
17730
17731 136077 head->dmisc5=dmisc5; //neck segments
17732
17733 /*
17734 if (dmisc3)
17735 {
17736 head->dummy_bool[0]=true;
17737 }
17738 */
17739
2/2
✓ Branch 0 taken 133797 times.
✓ Branch 1 taken 2280 times.
136077 if(head->hclk)
17740 {
17741
2/2
✓ Branch 0 taken 1802 times.
✓ Branch 1 taken 478 times.
2280 if(hclk==0)
17742 {
17743 478 hp -= 1000 - head->hp;
17744 478 hclk = 33;
17745
17746
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 478 times.
478 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
17747
17748 478 sfx(WAV_EHIT,pan(int32_t(head->x)));
17749 478 }
17750
17751 2280 head->hclk = 0;
17752 2280 }
17753
17754 // Must be set in case of naughty ZScripts
17755 136077 head->hp = 1000;
17756 136077 }
17757
17758
2/2
✓ Branch 0 taken 59594 times.
✓ Branch 1 taken 159 times.
59753 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
17759 {
17760 159 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
17761 159 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
17762 159 }
17763
17764
2/2
✓ Branch 0 taken 18578 times.
✓ Branch 1 taken 41175 times.
59753 if(!dmisc3)
17765 {
17766
4/4
✓ Branch 0 taken 2278 times.
✓ Branch 1 taken 38897 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 1721 times.
41175 if(++clk2>72 && !(zc_oldrand()&3))
17767 {
17768 557 int32_t i=zc_oldrand()%misc;
17769 557 enemy *head = ((enemy*)guys.spr(index+i+1));
17770 557 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
17771 557 sfx(wpnsfx(wpn),pan(int32_t(x)));
17772 557 clk2=0;
17773 557 }
17774 41175 }
17775 else
17776 {
17777
4/4
✓ Branch 0 taken 779 times.
✓ Branch 1 taken 17799 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 181 times.
18578 if(++clk2>100 && !(zc_oldrand()&3))
17778 {
17779 181 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
17780 181 head->timer=zc_oldrand()%50+50;
17781 181 clk2=0;
17782 181 }
17783 }
17784
17785
3/4
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 59694 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 59 times.
59753 if((hp<=0 && !immortal))
17786 {
17787
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 59 times.
212 for(int32_t i=0; i<misc; i++)
17788 153 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
17789
17790
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 56 times.
59 if(flags&guy_neverret) never_return(index);
17791 59 }
17792
17793 59753 return enemy::animate(index);
17794 60815 }
17795
17796 141 int32_t eGleeok::takehit(weapon*,weapon*)
17797 {
17798 141 return 0;
17799 }
17800
17801 61133 void eGleeok::draw(BITMAP *dest)
17802 {
17803 61133 tile=o_tile;
17804
17805
2/2
✓ Branch 0 taken 1062 times.
✓ Branch 1 taken 60071 times.
61133 if(dying)
17806 {
17807 1062 enemy::draw(dest);
17808 1062 return;
17809 }
17810
17811 60071 int32_t f=clk/17;
17812
17813
2/2
✓ Branch 0 taken 43721 times.
✓ Branch 1 taken 16350 times.
60071 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17814 {
17815 // body
17816 43721 xofs=-8;
17817 43721 yofs=32;
17818
17819
4/4
✓ Branch 0 taken 33457 times.
✓ Branch 1 taken 3611 times.
✓ Branch 2 taken 3364 times.
✓ Branch 3 taken 3289 times.
43721 switch(f)
17820
17821 {
17822 case 0:
17823 3611 tile+=0;
17824 3611 break;
17825
17826 case 1:
17827 3364 tile+=2;
17828 3364 break;
17829
17830 case 2:
17831 3289 tile+=4;
17832 3289 break;
17833
17834 default:
17835 33457 tile+=6;
17836 33457 break;
17837 }
17838 43721 }
17839 else
17840 {
17841 // body
17842 16350 xofs=-8;
17843 16350 yofs=32;
17844
17845
3/3
✓ Branch 0 taken 14042 times.
✓ Branch 1 taken 1169 times.
✓ Branch 2 taken 1139 times.
16350 switch(f)
17846 {
17847 case 0:
17848 1169 tile+=0;
17849 1169 break;
17850
17851 case 2:
17852 1139 tile+=4;
17853 1139 break;
17854
17855 default:
17856 14042 tile+=2;
17857 14042 break;
17858 }
17859 }
17860
17861 60071 enemy::drawblock(dest,15);
17862 61133 }
17863
17864 61133 void eGleeok::draw2(BITMAP *dest)
17865 {
17866 // the neck stub
17867 61133 tile=necktile;
17868 61133 xofs=0;
17869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61133 times.
61133 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17870
17871
2/2
✓ Branch 0 taken 16602 times.
✓ Branch 1 taken 44531 times.
61133 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17872 {
17873 44531 tile+=((clk&24)>>3);
17874 44531 }
17875
17876
3/4
✓ Branch 0 taken 60071 times.
✓ Branch 1 taken 1062 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60071 times.
61133 if(hp > 0 && !dont_draw())
17877 {
17878
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60071 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60071 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
17879 sprite::drawcloaked(dest);
17880 else
17881 60071 sprite::draw(dest);
17882 60071 }
17883 61133 }
17884
17885
4/8
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 230 times.
✗ Branch 7 not taken.
690 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17886 460 {
17887
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 xoffset=0;
17888
2/4
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
230 yoffset=(zfix)((dmisc5*4+2));
17889 // dummy_bool[0]=false;
17890 230 timer=0;
17891 /* fixing */
17892 230 hp=1000;
17893
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 step=1;
17894 230 item_set=0;
17895 //x=120; y=70;
17896
4/8
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 230 times.
✗ Branch 7 not taken.
230 x = xoffset+parent->x;
17897
4/8
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 230 times.
✗ Branch 7 not taken.
230 y = yoffset+parent->y;
17898 230 hxofs=4;
17899 230 hxsz=8;
17900
3/6
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 230 times.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
230 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17901 230 clk2=clk; // how int32_t to wait before moving first time
17902 230 clk=0;
17903 230 mainguy=count_enemy=false;
17904
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 dir=zc_oldrand();
17905 230 clk3=((dir&2)>>1)+2; // left or right
17906 230 dir&=1; // up or down
17907
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 dmisc5=vbound(dmisc5,1,255);
17908 230 isCore = false;
17909
1/2
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
230 parentCore = parent->getUID();
17910
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 230 times.
1150 for(int32_t i=0; i<dmisc5; i++)
17911 {
17912 920 nxoffset[i] = 0;
17913 920 nyoffset[i] = 0;
17914
2/4
✓ Branch 0 taken 920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 920 times.
✗ Branch 3 not taken.
920 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
17915
2/4
✓ Branch 0 taken 920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 920 times.
✗ Branch 3 not taken.
920 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
17916 920 }
17917
17918 230 necktile=0;
17919 //TODO compatibility? -DD
17920 /*
17921 for(int32_t i=0; i<4; i++)
17922 {
17923 nx[i]=124;
17924 ny[i]=i*6+48;
17925 }*/
17926 230 bgsfx=-1;
17927 //no need for deadsfx
17928 230 }
17929
17930 175322 bool esGleeok::animate(int32_t index)
17931 {
17932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175322 times.
175322 if(switch_hooked) return enemy::animate(index);
17933 // don't call removearmos() - it's a segment.
17934
17935 175322 dmisc5=vbound(dmisc5,1,255);
17936
17937
2/2
✓ Branch 0 taken 39398 times.
✓ Branch 1 taken 135924 times.
175322 if(misc == 0)
17938 {
17939 135924 x = (xoffset+parent->x);
17940 135924 y = (yoffset+parent->y);
17941
17942
2/2
✓ Branch 0 taken 543696 times.
✓ Branch 1 taken 135924 times.
679620 for(int32_t i=0; i<dmisc5; i++)
17943 {
17944 543696 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
17945 543696 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
17946 543696 }
17947 135924 }
17948
17949 // set up the head tiles
17950 // headtile=nets+5588; //5580, actually. must adjust for direction later on
17951 /*
17952 if (dummy_bool[0]) //if this is a flame gleeok
17953 {
17954 headtile+=180;
17955 }
17956 */
17957 175322 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
17958 175322 flyingheadtile=dummy_int[3];
17959
17960 // set up the neck tiles
17961 175322 necktile=dummy_int[1];
17962
17963
2/2
✓ Branch 0 taken 122856 times.
✓ Branch 1 taken 52466 times.
175322 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17964 {
17965 122856 necktile+=((clk&24)>>3);
17966 122856 }
17967
17968 /*
17969 else
17970 {
17971 necktile=145;
17972 }
17973 */
17974 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
17975
17976
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 135924 times.
✓ Branch 2 taken 39121 times.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 165 times.
175322 switch(misc)
17977 {
17978 case 0: // live head
17979 // set up the attached head tiles
17980 135924 tile=headtile;
17981
17982
2/2
✓ Branch 0 taken 98694 times.
✓ Branch 1 taken 37230 times.
135924 if(get_bit(quest_rules,qr_NEWENEMYTILES))
17983 {
17984 98694 tile+=((clk&24)>>3);
17985 /*
17986 if (dummy_bool[0]) {
17987 tile+=1561;
17988 }
17989 */
17990 98694 }
17991
17992 /*
17993 else
17994 {
17995 tile=146;
17996 }
17997 */
17998
4/4
✓ Branch 0 taken 34657 times.
✓ Branch 1 taken 101267 times.
✓ Branch 2 taken 3844 times.
✓ Branch 3 taken 30813 times.
135924 if(++clk2>=0 && !(clk2&3))
17999 {
18000
2/2
✓ Branch 0 taken 30143 times.
✓ Branch 1 taken 670 times.
30813 if(y<= (int32_t)parent->y + 8) dir=down;
18001
18002
2/2
✓ Branch 0 taken 30175 times.
✓ Branch 1 taken 638 times.
30813 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
18003
18004
4/4
✓ Branch 0 taken 3217 times.
✓ Branch 1 taken 27596 times.
✓ Branch 2 taken 3131 times.
✓ Branch 3 taken 86 times.
30813 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
18005 {
18006 86 dir^=1;
18007 86 }
18008
18009 30813 zfix tempx = x;
18010 30813 zfix tempy = y;
18011
18012 30813 sprite::move(step);
18013 30813 xoffset += (x-tempx);
18014 30813 yoffset += (y-tempy);
18015
18016
2/2
✓ Branch 0 taken 1277 times.
✓ Branch 1 taken 29536 times.
30813 if(clk2>=4)
18017 {
18018 1277 clk3^=1;
18019 1277 clk2=-4;
18020 1277 }
18021 else
18022 {
18023
2/2
✓ Branch 0 taken 29232 times.
✓ Branch 1 taken 304 times.
29536 if(x <= (int32_t)parent->x-(dmisc5*6))
18024 {
18025 304 clk3=right;
18026 304 }
18027
18028
2/2
✓ Branch 0 taken 29207 times.
✓ Branch 1 taken 329 times.
29536 if(x >= (int32_t)parent->x+(dmisc5*6))
18029 {
18030 329 clk3=left;
18031 329 }
18032
18033
4/4
✓ Branch 0 taken 19921 times.
✓ Branch 1 taken 9615 times.
✓ Branch 2 taken 18716 times.
✓ Branch 3 taken 1205 times.
29536 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
18034 {
18035 1205 clk3^=1; // x jig
18036 1205 }
18037 else
18038 {
18039
4/4
✓ Branch 0 taken 9779 times.
✓ Branch 1 taken 18552 times.
✓ Branch 2 taken 9482 times.
✓ Branch 3 taken 297 times.
28331 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
18040 {
18041 297 clk3^=1; // x switch back
18042 297 }
18043
18044 28331 clk2=-4;
18045 }
18046 }
18047
18048 30813 zc_swap(dir,clk3);
18049 30813 tempx = x;
18050 30813 tempy = y;
18051 30813 sprite::move(step);
18052 30813 xoffset += (x-tempx);
18053 30813 yoffset += (y-tempy);
18054 30813 zc_swap(dir,clk3);
18055
18056
2/2
✓ Branch 0 taken 92439 times.
✓ Branch 1 taken 30813 times.
123252 for(int32_t i=1; i<dmisc5; i++)
18057 {
18058 92439 nxoffset[i] = (zc_oldrand()%3);
18059 92439 nyoffset[i] = (zc_oldrand()%3);
18060 92439 }
18061 30813 }
18062
18063 135924 break;
18064
18065 case 1: // flying head
18066
2/2
✓ Branch 0 taken 2300 times.
✓ Branch 1 taken 36821 times.
39121 if(clk>=0)
18067
18068 {
18069 36821 variable_walk_8(rate,homing,hrate,spw_floater);
18070 36821 }
18071
18072 39121 break;
18073
18074 // the following are messages sent from the main guy...
18075 case -1: // got chopped off
18076 {
18077 112 misc=1;
18078 112 superman=1;
18079 112 hxofs=xofs=0;
18080 112 hxsz=16;
18081 112 cs=8;
18082 112 clk=-24;
18083 112 clk2=40;
18084 112 dir=(zc_oldrand()&7)+8;
18085 112 step=8.0/9.0;
18086 }
18087 112 break;
18088
18089 case -2: // the big guy is dead
18090 165 return true;
18091 }
18092
18093
2/2
✓ Branch 0 taken 162831 times.
✓ Branch 1 taken 12326 times.
175157 if(timer)
18094 {
18095
2/2
✓ Branch 0 taken 10857 times.
✓ Branch 1 taken 1469 times.
12326 if(!(timer%8))
18096 {
18097 1469 FireBreath(true);
18098 1469 }
18099
18100 12326 --timer;
18101 12326 }
18102
18103 175157 return enemy::animate(index);
18104 175322 }
18105
18106 2909 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
18107 {
18108
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2909 if ((editorflags & ENEMY_FLAG7) && misc == 1)
18109 {
18110 int32_t wpnId = w->id;
18111
18112 if(dying)
18113 return 0;
18114
18115 switch(wpnId)
18116 {
18117 case wLitBomb:
18118 case wLitSBomb:
18119 case wBait:
18120 case wWhistle:
18121 case wFire:
18122 case wWind:
18123 case wSSparkle:
18124 case wFSparkle:
18125 case wPhantom:
18126 return 0;
18127
18128 case wHookshot:
18129 case wBrang:
18130 case wBeam:
18131 case wArrow:
18132 case wMagic:
18133 case wBomb:
18134 case wSBomb:
18135 sfx(WAV_CHINK,pan(int32_t(x)));
18136 break;
18137 default:
18138 break;
18139 }
18140
18141 return 1;
18142 }
18143 else
18144 {
18145 2909 int32_t ret = enemy::takehit(w,realweap);
18146
18147
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 2280 times.
2909 if(ret==-1)
18148 2280 return 2; // force it to wait a frame before checking sword attacks again
18149
18150 629 return ret;
18151 }
18152 2909 }
18153
18154 176009 void esGleeok::draw(BITMAP *dest)
18155 {
18156 176009 dmisc5=vbound(dmisc5,1,255);
18157
18158
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 136788 times.
✓ Branch 2 taken 39221 times.
176009 switch(misc)
18159 {
18160 case 0: //neck
18161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136788 times.
136788 if(!dont_draw())
18162 {
18163
2/2
✓ Branch 0 taken 410364 times.
✓ Branch 1 taken 136788 times.
547152 for(int32_t i=1; i<dmisc5; i++) //draw the neck
18164 {
18165
2/2
✓ Branch 0 taken 298542 times.
✓ Branch 1 taken 111822 times.
410364 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18166 {
18167
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 298542 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
298542 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18168 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
18169 else
18170 298542 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
18171 298542 }
18172 else
18173 {
18174
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 111822 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
111822 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
18175 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
18176 else
18177 111822 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
18178 }
18179 410364 }
18180 136788 }
18181
18182 136788 break;
18183
18184 case 1: //flying head
18185 39221 tile=flyingheadtile;
18186
18187
2/2
✓ Branch 0 taken 15192 times.
✓ Branch 1 taken 24029 times.
39221 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18188 {
18189 24029 tile+=((clk&24)>>3);
18190 24029 break;
18191 }
18192
18193 /*
18194 else
18195 {
18196 tile=(clk&1)?147:148;
18197 break;
18198 }
18199 */
18200 15192 }
18201 176009 }
18202
18203 176009 void esGleeok::draw2(BITMAP *dest)
18204 {
18205 176009 enemy::draw(dest);
18206 176009 }
18207
18208 90 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
18209 90 {
18210
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if ( !(editorflags & ENEMY_FLAG5) )
18211 {
18212
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 x = 128;
18213
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 y = 48;
18214 45 }
18215 else { x = X; y = Y; }
18216 45 adjusted=false;
18217
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 dir=(zc_oldrand()&7)+8;
18218 //step=0.25;
18219 45 flycnt=dmisc1;
18220 45 flycnt2=dmisc2;
18221 45 loopcnt=0;
18222 45 clk4 = 0;
18223 45 clk5 = 0;
18224 45 clk6 = 0;
18225 45 clk7 = 0;
18226
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
18227 45 SIZEflags = d->SIZEflags;
18228
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
18229
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
18230 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
18231 // al_trace("Enemy txsz:%i\n", txsz);
18232
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
18233
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
18234
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = hxsz;
18235
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 else if (dmisc10 == 1) hxsz = 32;
18236
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = hysz;
18237
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
18238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
18239
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 else if (dmisc10 == 1) hxofs = -8;
18240
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
18241 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
18242
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
18243
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
45 else if (dmisc10 == 1) xofs = -8;
18244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
18245 {
18246 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
18247 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
18248 }
18249
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
45 else if (dmisc10 == 1) yofs = (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
18250
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if (editorflags & ENEMY_FLAG8) misc = 1;
18251
18252
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
45 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
18253
18254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dmisc29 == 0)
18255 {
18256
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28 times.
45 if(!dmisc4)
18257 {
18258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if (dmisc10) dmisc29 = (90 / 3);
18259 28 else dmisc29 = (84 / 3);
18260 28 }
18261 else
18262 {
18263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (dmisc10) dmisc29 = (90 / 2);
18264 17 else dmisc29 = (84 / 2);
18265 }
18266 45 }
18267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dmisc30 == 0)
18268 {
18269
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28 times.
45 if(!dmisc4)
18270 {
18271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if (dmisc10) dmisc30 = (90 / 3)*0.5;
18272 28 else dmisc30 = (84 / 3)*0.5;
18273 28 }
18274 else
18275 {
18276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (dmisc10) dmisc30 = (90 / 2)*0.5;
18277 17 else dmisc30 = (84 / 2)*0.5;
18278 }
18279 45 }
18280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dmisc31 == 0)
18281 {
18282
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28 times.
45 if(!dmisc4)
18283 {
18284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if (dmisc10) dmisc31 = (90 / 3)*2;
18285 28 else dmisc31 = (84 / 3)*2;
18286 28 }
18287 else
18288 {
18289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (dmisc10) dmisc31 = (90 / 2)*0.5;
18290 17 else dmisc31 = (84 / 2)*0.5;
18291 }
18292 45 }
18293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if (dmisc32 == 0)
18294 {
18295
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 28 times.
45 if(!dmisc4)
18296 {
18297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if (dmisc10) dmisc32 = (90 / 3);
18298 28 else dmisc32 = (84 / 3);
18299 28 }
18300 else
18301 {
18302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if (dmisc10) dmisc32 = (90 / 2)*0.25;
18303 17 else dmisc32 = (84 / 2)*0.25;
18304 }
18305 45 }
18306 45 }
18307
18308 55559 bool ePatra::animate(int32_t index)
18309 {
18310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55559 times.
55559 if(switch_hooked) return enemy::animate(index);
18311
2/2
✓ Branch 0 taken 702 times.
✓ Branch 1 taken 54857 times.
55559 if(dying)
18312 {
18313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 702 times.
702 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
18314 {
18315 ((enemy*)guys.spr(i))->hp = -1000;
18316 }
18317
18318 702 return Dead(index);
18319 }
18320
18321 54857 double basesize = 84;
18322
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (dmisc10) basesize = 90;
18323 54857 double halfsize = basesize / 2;
18324 54857 double quartersize = halfsize / 2;
18325 54857 double twothirdsize = (basesize / 3)*2;
18326 54857 double onethirdsize = (basesize / 3);
18327
18328
18329
2/2
✓ Branch 0 taken 12020 times.
✓ Branch 1 taken 42837 times.
54857 if(clk==0)
18330 {
18331 12020 removearmos(x,y,ffcactivated);
18332 12020 }
18333
18334
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54857 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
54857 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
18335 {
18336
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
54857 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
18337
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (loopcnt < 0) ++clk2;
18338
2/2
✓ Branch 0 taken 54237 times.
✓ Branch 1 taken 620 times.
54857 if(++clk2>basesize)
18339 {
18340 620 clk2=0;
18341
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 620 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
620 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
18342 {
18343
2/2
✓ Branch 0 taken 322 times.
✓ Branch 1 taken 298 times.
620 if(loopcnt > 0)
18344 322 --loopcnt;
18345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 298 times.
298 else if (loopcnt == 0)
18346 {
18347
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 114 times.
298 if((misc%dmisc6)==0)
18348 {
18349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 114 times.
114 if (dmisc21 > 0) loopcnt=-dmisc21;
18350 114 else loopcnt=dmisc7;
18351 114 }
18352 298 }
18353 else if (loopcnt == -1) loopcnt=dmisc7;
18354 else ++loopcnt;
18355
18356
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
620 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
18357 620 }
18358 else
18359 {
18360 loopcnt = 0;
18361 misc = 1;
18362 }
18363 620 }
18364 54857 }
18365
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (clk4 > 0) --clk4;
18366
18367 54857 double size=1;
18368
18369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
54857 if (clk6 < 0)
18370 {
18371 if (dmisc5 == 1 || dmisc5 == 3)
18372 {
18373 if (get_bit(quest_rules,qr_NEWENEMYTILES))
18374 {
18375 if (clk7 <= 0 || clk6 != -16) ++clk6;
18376 if (clk6 == 0) o_tile=d->e_tile;
18377 else
18378 {
18379 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
18380 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
18381 }
18382 }
18383 else clk6 = 0;
18384 }
18385 }
18386
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 else if (dmisc19) ++clk6;
18387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
54857 if (clk5 < 0) ++clk5;
18388
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 else if (dmisc19) ++clk5;
18389
18390
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54857 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54857 if (clk7 > 0 && clk6 >= -16) --clk7;
18391
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (clk6 > 0) clk7 = 0;
18392
18393
2/2
✓ Branch 0 taken 211948 times.
✓ Branch 1 taken 54857 times.
266805 for(int32_t i=index+1; i<index+flycnt+1; i++)
18394 {
18395 //outside ring
18396
2/2
✓ Branch 0 taken 211588 times.
✓ Branch 1 taken 360 times.
211948 if(!adjusted)
18397 {
18398
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 88 times.
360 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18399 {
18400 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
18401 272 enemy *s = ((enemy*)guys.spr(i));
18402 272 s->parent_script_UID = this->script_UID;
18403 272 }
18404 else
18405 {
18406 88 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18407 88 enemy *s = ((enemy*)guys.spr(i));
18408 88 s->parent_script_UID = this->script_UID;
18409 }
18410
18411 360 ((enemy*)guys.spr(i))->cs=dmisc9;
18412 360 ((enemy*)guys.spr(i))->hp=dmisc3;
18413 360 }
18414
18415
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 211636 times.
211948 if(((enemy*)guys.spr(i))->hp <= 0)
18416 {
18417
2/2
✓ Branch 0 taken 1189 times.
✓ Branch 1 taken 312 times.
1501 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18418 {
18419 1189 guys.swap(j,j+1);
18420 1189 }
18421
18422
3/4
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 273 times.
✓ Branch 2 taken 39 times.
✗ Branch 3 not taken.
312 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
18423 312 }
18424 else
18425 {
18426 211636 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18427
1/2
✓ Branch 0 taken 211636 times.
✗ Branch 1 not taken.
211636 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
18428
18429
2/2
✓ Branch 0 taken 77505 times.
✓ Branch 1 taken 134131 times.
211636 if(!dmisc4) //Big Ring
18430 {
18431 //maybe playing_field_offset here?
18432
2/2
✓ Branch 0 taken 61214 times.
✓ Branch 1 taken 72917 times.
134131 if(loopcnt>0)
18433 {
18434
1/2
✓ Branch 0 taken 72917 times.
✗ Branch 1 not taken.
72917 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18435
1/2
✓ Branch 0 taken 72917 times.
✗ Branch 1 not taken.
72917 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
18436 72917 }
18437 else
18438 {
18439 61214 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18440 61214 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18441 }
18442
18443 134131 temp_x=guys.spr(i)->x;
18444 134131 temp_y=guys.spr(i)->y;
18445 134131 }
18446 else //Oval
18447 {
18448 77505 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18449 77505 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
18450
18451
2/2
✓ Branch 0 taken 44593 times.
✓ Branch 1 taken 32912 times.
77505 if(loopcnt>0)
18452 {
18453 44593 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
18454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44593 times.
44593 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
18455 44593 }
18456 else
18457 {
18458 32912 guys.spr(i)->x = circle_x;
18459 32912 guys.spr(i)->y = circle_y;
18460 }
18461
18462 77505 temp_x=circle_x;
18463 77505 temp_y=circle_y;
18464 }
18465
18466 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18467 211636 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18468
18469
4/4
✓ Branch 0 taken 40124 times.
✓ Branch 1 taken 171512 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26858 times.
211636 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18470 {
18471 26858 guys.spr(i)->dir=l_down;
18472 26858 }
18473
4/4
✓ Branch 0 taken 40238 times.
✓ Branch 1 taken 144540 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26972 times.
184778 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18474 {
18475 26972 guys.spr(i)->dir=left;
18476 26972 }
18477
4/4
✓ Branch 0 taken 40004 times.
✓ Branch 1 taken 117802 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26738 times.
157806 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18478 {
18479 26738 guys.spr(i)->dir=l_up;
18480 26738 }
18481
4/4
✓ Branch 0 taken 39715 times.
✓ Branch 1 taken 91353 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26449 times.
131068 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18482 {
18483 26449 guys.spr(i)->dir=up;
18484 26449 }
18485
4/4
✓ Branch 0 taken 39428 times.
✓ Branch 1 taken 65191 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 26162 times.
104619 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18486 {
18487 26162 guys.spr(i)->dir=r_up;
18488 26162 }
18489
4/4
✓ Branch 0 taken 39237 times.
✓ Branch 1 taken 39220 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 25971 times.
78457 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18490 {
18491 25971 guys.spr(i)->dir=right;
18492 25971 }
18493
4/4
✓ Branch 0 taken 39264 times.
✓ Branch 1 taken 13222 times.
✓ Branch 2 taken 13266 times.
✓ Branch 3 taken 25998 times.
52486 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18494 {
18495 25998 guys.spr(i)->dir=r_down;
18496 25998 }
18497 else
18498 {
18499 26488 guys.spr(i)->dir=down;
18500 }
18501
18502 211636 guys.spr(i)->x += x;
18503 211636 guys.spr(i)->y += y;
18504 }
18505 211948 }
18506
18507
7/22
✓ Branch 0 taken 33241 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33241 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
54857 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
18508 {
18509 15803 int timeneeded = 48;
18510 15803 int patbreath = (zc_oldrand()%50+50);
18511
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
18512
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
18513 {
18514 timeneeded = 48 + patbreath;
18515 }
18516
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
18517 {
18518 timeneeded = 48 + 96;
18519 }
18520
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
18521
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
18522
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18523 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)))))
18524 133 && (clk6 >= 0) //if not in the middle of firing...
18525 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
18526
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
18527 {
18528
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
18529 {
18530 case patratSTREAM:
18531 {
18532 clk7 = 97;
18533 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18534 else clk6 = 0;
18535 break;
18536 }
18537 case patratBREATH:
18538 {
18539 clk7 = patbreath;
18540 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) clk6 = -48;
18541 else clk6 = 0;
18542 break;
18543 }
18544 default:
18545 {
18546
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18547 {
18548 clk6 = -48;
18549 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18550 }
18551 else
18552 {
18553 133 clk6 = 0;
18554
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18555 133 FirePatraWeapon();
18556 }
18557 133 break;
18558 }
18559 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18560 133 }
18561
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
18562 {
18563 switch(dmisc28)
18564 {
18565 case patratSTREAM:
18566 {
18567 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
18568 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18569 break;
18570 }
18571 case patratBREATH:
18572 {
18573 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
18574 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18575 break;
18576 }
18577 default:
18578 {
18579 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && clk6 == -16)
18580 {
18581 FirePatraWeapon();
18582 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
18583 }
18584 break;
18585 }
18586 }
18587 }
18588 15803 }
18589
18590 54857 size=.5;
18591 54857 int randattempts = 0;
18592 54857 int randeye = 0;
18593
2/2
✓ Branch 0 taken 38255 times.
✓ Branch 1 taken 16602 times.
54857 if (flycnt2 > 0)
18594 {
18595 16602 do
18596 {
18597
2/4
✓ Branch 0 taken 16602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
18598 16602 randeye += (index + flycnt + 1);
18599 16602 ++randattempts;
18600
2/4
✓ Branch 0 taken 16602 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
18601 16602 }
18602 54857 bool dofire = false;
18603
1/2
✓ Branch 0 taken 54857 times.
✗ Branch 1 not taken.
54857 if (dmisc20)
18604 {
18605 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18606 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
18607 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
18608 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) || dmisc20 == 2))
18609 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
18610 {
18611 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18612 {
18613 if (clk5 >= dmisc19)
18614 {
18615 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18616 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
18617 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
18618 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
18619 || dmisc18 == -1)
18620 dofire = true;
18621 }
18622 }
18623 }
18624 }
18625
2/2
✓ Branch 0 taken 38255 times.
✓ Branch 1 taken 16602 times.
54857 if(flycnt2)
18626 {
18627
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
18628 {
18629
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
18630 {
18631 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
18632
18633
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_bit(quest_rules,qr_NEWENEMYTILES))
18634 {
18635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18636 {
18637
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
18638 {
18639 // Center eye shoots projectiles; make room for its firing tiles
18640 case 1:
18641 case 3:
18642 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
18643 48 break;
18644
18645 // Center eyes does not shoot; use tiles two rows below for inner eyes.
18646 default:
18647 case 2:
18648 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
18649 40 break;
18650 }
18651 88 }
18652 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
18653 88 }
18654 else
18655 {
18656 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
18657 }
18658
18659 88 ((enemy*)guys.spr(i))->cs=dmisc9;
18660
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
18661 88 }
18662
18663
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
18664 {
18665 94136 ((enemy*)guys.spr(i))->superman=true;
18666 94136 }
18667 else
18668 {
18669 25839 ((enemy*)guys.spr(i))->superman=false;
18670 }
18671
18672
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
18673 {
18674
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
18675 {
18676 144 guys.swap(j,j+1);
18677 144 }
18678
18679
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
18680 72 }
18681 else
18682 {
18683 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
18684
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
18685
18686
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
18687 {
18688
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
18689 {
18690
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18691
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
18692 58268 }
18693 else
18694 {
18695 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18696 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18697 }
18698
18699 112644 temp_x=guys.spr(i)->x;
18700 112644 temp_y=guys.spr(i)->y;
18701 112644 }
18702 else
18703 {
18704 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18705 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
18706
18707
2/2
✓ Branch 0 taken 3294 times.
✓ Branch 1 taken 3965 times.
7259 if(loopcnt>0)
18708 {
18709 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
18710
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
18711 3965 }
18712 else
18713 {
18714 3294 guys.spr(i)->x = circle_x;
18715 3294 guys.spr(i)->y = circle_y;
18716 }
18717
18718 7259 temp_x=circle_x;
18719 7259 temp_y=circle_y;
18720 }
18721
18722 double _MSVC2022_tmp1, _MSVC2022_tmp2;
18723 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
18724
18725
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
18726 {
18727 14941 guys.spr(i)->dir=l_down;
18728 14941 }
18729
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
18730 {
18731 14928 guys.spr(i)->dir=left;
18732 14928 }
18733
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
18734 {
18735 14937 guys.spr(i)->dir=l_up;
18736 14937 }
18737
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
18738 {
18739 14996 guys.spr(i)->dir=up;
18740 14996 }
18741
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
18742 {
18743 15041 guys.spr(i)->dir=r_up;
18744 15041 }
18745
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
18746 {
18747 15035 guys.spr(i)->dir=right;
18748 15035 }
18749
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
18750 {
18751 15035 guys.spr(i)->dir=r_down;
18752 15035 }
18753 else
18754 {
18755 14990 guys.spr(i)->dir=down;
18756 }
18757
18758 119903 guys.spr(i)->x += x;
18759 119903 guys.spr(i)->y = y-guys.spr(i)->y;
18760
18761
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
18762 {
18763 /*
18764 if(!(zc_oldrand()&127))
18765 {
18766 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
18767 sfx(wpnsfx(wpn),pan(int32_t(x)));
18768 }
18769 */
18770
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
18771 {
18772 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
18773 if (get_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS))
18774 {
18775 if (dmisc5 == 3)
18776 {
18777 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18778 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
18779 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
18780 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18781 }
18782 else
18783 {
18784 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18785 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
18786 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
18787 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
18788 }
18789 }
18790 else
18791 {
18792 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18793 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
18794 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
18795 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
18796 }
18797 }
18798
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
18799
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
18800
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
18801 {
18802
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
18803 {
18804 case 4: //Single one rapidfires
18805 {
18806 if (dofire && i == randeye)
18807 {
18808 ((esPatra*)guys.spr(i))->clk5 = -16;
18809 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
18810 ((esPatra*)guys.spr(i))->clk4 = 96;
18811 clk5 = -3;
18812 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18813 }
18814 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
18815 {
18816 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18817 sfx(wpnsfx(wpn),pan(int32_t(x)));
18818 }
18819 break;
18820 }
18821 case 3: //Ring
18822 {
18823 if (dofire)
18824 {
18825 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18826 {
18827 ((esPatra*)guys.spr(i))->clk5 = -48;
18828 clk5 = -48;
18829 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18830 }
18831 else
18832 {
18833 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18834 sfx(wpnsfx(wpn),pan(int32_t(x)));
18835 int32_t m=Ewpns.Count()-1;
18836 weapon *ew = (weapon*)(Ewpns.spr(m));
18837
18838 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18839 ((esPatra*)guys.spr(i))->clk5 = 0;
18840 clk5 = 0;
18841 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18842 }
18843 }
18844 if (((esPatra*)guys.spr(i))->clk5 == -16)
18845 {
18846 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18847 sfx(wpnsfx(wpn),pan(int32_t(x)));
18848 int32_t m=Ewpns.Count()-1;
18849 weapon *ew = (weapon*)(Ewpns.spr(m));
18850
18851 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
18852 }
18853 break;
18854 }
18855 case 2: //one after another
18856 {
18857 if (dofire)
18858 {
18859 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
18860 clk5 = -48 - (12*flycnt2);
18861 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
18862 }
18863 if (((esPatra*)guys.spr(i))->clk5 == -16)
18864 {
18865 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18866 sfx(wpnsfx(wpn),pan(int32_t(x)));
18867 }
18868 break;
18869 }
18870 case 1: //random one eye
18871 {
18872 if (dofire && i == randeye)
18873 {
18874 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18875 {
18876 ((esPatra*)guys.spr(i))->clk5 = -48;
18877 clk5 = -48;
18878 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18879 }
18880 else
18881 {
18882 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18883 sfx(wpnsfx(wpn),pan(int32_t(x)));
18884 ((esPatra*)guys.spr(i))->clk5 = 0;
18885 clk5 = 0;
18886 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18887 }
18888 }
18889 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18890 {
18891 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
18892 sfx(wpnsfx(wpn),pan(int32_t(x)));
18893 }
18894 break;
18895 }
18896 default: //old behavior, all eyes can fire any time
18897 {
18898
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
18899
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_bit(quest_rules,qr_NEWENEMYTILES))
18900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
18901 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
18902 {
18903
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES))
18904 {
18905 ((esPatra*)guys.spr(i))->clk5 = -48;
18906 if (editorflags & ENEMY_FLAG6) clk4 = 64;
18907 }
18908 else
18909 {
18910 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18911 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
18912 292 ((esPatra*)guys.spr(i))->clk5 = 0;
18913
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
18914 }
18915 292 }
18916
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_bit(quest_rules,qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
18917 {
18918 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
18919 sfx(wpnsfx(wpn),pan(int32_t(x)));
18920 }
18921 38077 break;
18922 }
18923 }
18924 38077 }
18925 38077 }
18926
18927 }
18928 119975 }
18929 16602 }
18930
18931 54857 adjusted=true;
18932 54857 return enemy::animate(index);
18933 55559 }
18934
18935 133 void ePatra::FirePatraWeapon()
18936 { //.707
18937 133 int32_t xoff = 0;
18938 133 int32_t yoff = 0;
18939
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
18940 {
18941 xoff += (hxsz/2)-8;
18942 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
18943 }
18944
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
18945 {
18946 yoff += (hysz/2)-8;
18947 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
18948 }
18949 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
18950
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
18951 {
18952 case patrat8SHOT: //Fire Wizzrobe
18953 case patrat4SHOTDIAG:
18954 case patrat4SHOTRAND:
18955 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
18956 {
18957 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
18958 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18959 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18960 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18961
18962 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
18963 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18964 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18965 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18966
18967 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
18968 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18969 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18970 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18971
18972 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
18973 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18974 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18975 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
18976
18977 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
18978 }
18979
18980 [[fallthrough]];
18981 case patrat4SHOTCARD: //Stalfos 3
18982 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
18983 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18984 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18985 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
18986 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18987 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18988 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
18989 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18990 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18991 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
18992 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
18993 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
18994 break;
18995
18996 default:
18997 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
18998
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
18999 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
19000
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19001
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19002 {
19003 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19004 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
19005 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19006 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19007 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19008 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
19009 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
19010 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19011 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
19012 {
19013 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19014 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
19015 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19016 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19017 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
19018 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
19019 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
19020 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
19021 }
19022 }
19023 133 break;
19024
19025 }
19026 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
19027 //+0.46364761
19028 //11.80
19029 133 }
19030
19031 111282 void ePatra::draw(BITMAP *dest)
19032 {
19033 111282 tile=o_tile;
19034 111282 update_enemy_frame();
19035 111282 enemy::draw(dest);
19036 111282 }
19037
19038 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
19039 {
19040 int32_t ret = enemy::defend(wpnId, power, edef);
19041
19042 if(ret < 0 && (flycnt||flycnt2))
19043 return 0;
19044
19045 return ret;
19046 }
19047
19048 780 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19049 {
19050 780 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19051
19052
6/6
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 382 times.
✓ Branch 3 taken 369 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 130 times.
780 if(ret < 0 && (flycnt||flycnt2))
19053 621 return 0;
19054
19055 159 return ret;
19056 780 }
19057
19058 1344 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19059 896 {
19060 //cs=8;
19061 448 item_set=0;
19062 448 misc=clk;
19063 448 clk4 = 0;
19064 448 clk5 = 0;
19065 448 clk = -((misc*21)>>1)-1;
19066
3/6
✓ Branch 0 taken 448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 448 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 448 times.
✗ Branch 5 not taken.
448 yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19067 448 hxsz=12;
19068 448 hysz=12;
19069 448 hxofs=2;
19070 448 hyofs=2;
19071 448 extend = 0;
19072 448 txsz = 1;
19073 448 tysz = 1;
19074 /* //These need to be separate enemy editor fields. This enemy class also it's draw altered to correctly support big stuff.
19075 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19076 int32_t prntSIZEflags = prntenemy->SIZEflags;
19077 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19078 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19079 // al_trace("Enemy txsz:%i\n", txsz);
19080 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19081 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19082 else
19083 hxsz=12;
19084 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19085 else
19086 hysz=12;
19087 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19088 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19089 else
19090 hxofs=2;
19091 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19092 else hyofs=2;
19093 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19094 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19095 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19096 {
19097 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19098 }
19099
19100 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
19101 */
19102 448 mainguy=count_enemy=false;
19103 448 bgsfx=-1;
19104 //o_tile=0;
19105 448 flags &= (~guy_neverret);
19106 448 deadsfx = WAV_EDEAD;
19107 448 hitsfx = WAV_EHIT;
19108 448 isCore = false;
19109 448 }
19110
19111 339094 bool esPatra::animate(int32_t index)
19112 {
19113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339094 times.
339094 if(switch_hooked) return enemy::animate(index);
19114
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 332182 times.
339094 if(dying)
19115 6912 return Dead(index);
19116
19117 332182 return enemy::animate(index);
19118 339094 }
19119
19120 680700 void esPatra::draw(BITMAP *dest)
19121 {
19122
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 135980 times.
680700 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19123 {
19124 544720 tile = o_tile+(clk&3);
19125
19126
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
19127 {
19128 case up: //u
19129 67770 flip=0;
19130 67770 break;
19131
19132 case down: //d
19133 69066 flip=0;
19134 69066 tile+=4;
19135 69066 break;
19136
19137 case left: //l
19138 67800 flip=0;
19139 67800 tile+=8;
19140 67800 break;
19141
19142 case right: //r
19143 67996 flip=0;
19144 67996 tile+=12;
19145 67996 break;
19146
19147 case l_up: //ul
19148 67484 flip=0;
19149 67484 tile+=20;
19150 67484 break;
19151
19152 case r_up: //ur
19153 68044 flip=0;
19154 68044 tile+=24;
19155 68044 break;
19156
19157 case l_down: //dl
19158 68474 flip=0;
19159 68474 tile+=28;
19160 68474 break;
19161
19162 case r_down: //dr
19163 68086 flip=0;
19164 68086 tile+=32;
19165 68086 break;
19166 }
19167 544720 }
19168 else
19169 {
19170 135980 tile = o_tile+((clk&2)>>1);
19171 }
19172
19173
2/2
✓ Branch 0 taken 33568 times.
✓ Branch 1 taken 647132 times.
680700 if(clk>=0)
19174 647132 enemy::draw(dest);
19175 680700 }
19176
19177
19178 6 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
19179 6 {
19180 3 adjusted=false;
19181
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
19182
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
19183 3 clk4 = 0;
19184 3 clk5 = 0;
19185 //flycnt=6; flycnt2=0;
19186 3 flycnt=dmisc1;
19187 3 flycnt2=0; // PatraBS doesn't have inner rings!
19188 3 loopcnt=0;
19189
19190 3 SIZEflags = d->SIZEflags;
19191
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19192 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19193 // al_trace("Enemy txsz:%i\n", txsz);
19194
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
19195
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = d->hxsz;
19196 3 else hxsz = 32;
19197
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = d->hysz;
19198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
19199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
19200 3 else hxofs=-8;
19201
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
19202 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19203
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
19204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19205 {
19206 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
19207 yofs += (get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
19208 }
19209
19210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
19211
19212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
19213
19214 //nets+4480;
19215 3 }
19216
19217 1862 bool ePatraBS::animate(int32_t index)
19218 {
19219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
19220
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
19221 54 return Dead(index);
19222
19223
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
19224 {
19225 442 removearmos(x,y,ffcactivated);
19226 442 }
19227
19228 1808 variable_walk_8(rate,homing,hrate,spw_floater);
19229
19230
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
19231 {
19232 19 clk2=0;
19233
19234
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
19235 12 --loopcnt;
19236 else
19237 {
19238
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
19239 4 loopcnt=dmisc7;
19240 }
19241
19242 19 ++misc;
19243 19 }
19244
19245 // double size=1;;
19246
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
19247 {
19248
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
19249 {
19250 18 ((enemy*)guys.spr(i))->hp=dmisc3;
19251
19252
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19253 {
19254 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
19255 18 }
19256 else
19257 {
19258 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
19259 }
19260
19261 18 ((enemy*)guys.spr(i))->cs = dmisc9;
19262 18 }
19263
19264
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
19265 {
19266
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
19267 {
19268 26 guys.swap(j,j+1);
19269 26 }
19270
19271 18 --flycnt;
19272 18 }
19273 else
19274 {
19275 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
19276
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
19277 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
19278 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
19279
19280
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
19281 {
19282 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
19283
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
19284 2305 }
19285 else
19286 {
19287 2132 guys.spr(i)->x = temp_x;
19288 2132 guys.spr(i)->y = temp_y;
19289 }
19290
19291 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19292 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
19293
19294
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19295 {
19296 551 guys.spr(i)->dir=l_down;
19297 551 }
19298
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19299 {
19300 534 guys.spr(i)->dir=left;
19301 534 }
19302
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19303 {
19304 522 guys.spr(i)->dir=l_up;
19305 522 }
19306
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19307 {
19308 564 guys.spr(i)->dir=up;
19309 564 }
19310
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19311 {
19312 545 guys.spr(i)->dir=r_up;
19313 545 }
19314
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19315 {
19316 562 guys.spr(i)->dir=right;
19317 562 }
19318
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19319 {
19320 554 guys.spr(i)->dir=r_down;
19321 554 }
19322 else
19323 {
19324 605 guys.spr(i)->dir=down;
19325 }
19326
19327 4437 guys.spr(i)->x += x;
19328 4437 guys.spr(i)->y += y;
19329 }
19330 4455 }
19331
19332 1808 adjusted=true;
19333 1808 return enemy::animate(index);
19334 1862 }
19335
19336 3724 void ePatraBS::draw(BITMAP *dest)
19337 {
19338 3724 tile=o_tile;
19339
19340
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19341 {
19342 double _MSVC2022_tmp1, _MSVC2022_tmp2;
19343 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
19344
19345
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
19346 {
19347 102 lookat=l_down;
19348 102 }
19349
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
19350 {
19351 310 lookat=down;
19352 310 }
19353
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
19354 {
19355 952 lookat=r_down;
19356 952 }
19357
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
19358 {
19359 1686 lookat=right;
19360 1686 }
19361
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
19362 {
19363 180 lookat=r_up;
19364 180 }
19365
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
19366 {
19367 lookat=up;
19368 }
19369
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
19370 {
19371 lookat=l_up;
19372 }
19373 else
19374 {
19375 494 lookat=left;
19376 }
19377
19378
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
19379 {
19380 case up: //u
19381 flip=0;
19382 break;
19383
19384 case down: //d
19385 310 flip=0;
19386 310 tile+=8;
19387 310 break;
19388
19389 case left: //l
19390 494 flip=0;
19391 494 tile+=40;
19392 494 break;
19393
19394 case right: //r
19395 1686 flip=0;
19396 1686 tile+=48;
19397 1686 break;
19398
19399 case l_up: //ul
19400 flip=0;
19401 tile+=80;
19402 break;
19403
19404 case r_up: //ur
19405 180 flip=0;
19406 180 tile+=88;
19407 180 break;
19408
19409 case l_down: //dl
19410 102 flip=0;
19411 102 tile+=120;
19412 102 break;
19413
19414 case r_down: //dr
19415 952 flip=0;
19416 952 tile+=128;
19417 952 break;
19418 }
19419
19420 3724 tile+=(2*(clk&3));
19421 3724 xofs-=8;
19422 3724 yofs-=8;
19423 3724 drawblock(dest,15);
19424 3724 xofs+=8;
19425 3724 yofs+=8;
19426 3724 }
19427 else
19428 {
19429 flip=(clk&1);
19430 xofs-=8;
19431 yofs-=8;
19432 enemy::draw(dest);
19433 xofs+=16;
19434 enemy::draw(dest);
19435 yofs+=16;
19436 enemy::draw(dest);
19437 xofs-=16;
19438 enemy::draw(dest);
19439 xofs+=8;
19440 yofs-=8;
19441 }
19442 3724 }
19443
19444 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
19445 {
19446 int32_t ret = enemy::defend(wpnId, power, edef);
19447
19448 if(ret < 0 && (flycnt||flycnt2))
19449 return 0;
19450
19451 return ret;
19452 }
19453
19454 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
19455 {
19456 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
19457
19458
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
19459 19 return 0;
19460
19461 6 return ret;
19462 25 }
19463
19464 54 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
19465 36 {
19466 //cs=csBOSS;
19467 18 item_set=0;
19468 18 misc=clk;
19469 18 clk = -((misc*21)>>1)-1;
19470 18 clk4 = 0;
19471 18 clk5 = 0;
19472
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
19473 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
19474
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
19475 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
19476 // al_trace("Enemy txsz:%i\n", txsz);
19477
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
19478
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
19479 18 else hxsz=16;
19480
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
19481 18 else hysz=16;
19482
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
19483
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
19484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
19485 18 else hyofs=2;
19486 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
19487
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
19488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
19489 {
19490 yofs = (int32_t)prntenemy->yofs;
19491 }
19492
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
18 else yofs=(get_bit(quest_rules, qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
19493
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
19494
19495 18 bgsfx=-1;
19496 18 mainguy=count_enemy=false;
19497 18 deadsfx = WAV_EDEAD;
19498 18 hitsfx = WAV_EHIT;
19499 18 flags &= ~guy_neverret;
19500 18 isCore = false;
19501 18 }
19502
19503 4790 bool esPatraBS::animate(int32_t index)
19504 {
19505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
19506
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
19507 324 return Dead(index);
19508
19509 4466 return enemy::animate(index);
19510 4790 }
19511
19512 9580 void esPatraBS::draw(BITMAP *dest)
19513 {
19514 9580 tile=o_tile;
19515
19516
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_bit(quest_rules,qr_NEWENEMYTILES))
19517 {
19518
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
19519 {
19520 case up: //u
19521 1280 flip=0;
19522 1280 break;
19523
19524 case down: //d
19525 1326 flip=0;
19526 1326 tile+=4;
19527 1326 break;
19528
19529 case left: //l
19530 1076 flip=0;
19531 1076 tile+=8;
19532 1076 break;
19533
19534 case right: //r
19535 1254 flip=0;
19536 1254 tile+=12;
19537 1254 break;
19538
19539 case l_up: //ul
19540 1080 flip=0;
19541 1080 tile+=20;
19542 1080 break;
19543
19544 case r_up: //ur
19545 1238 flip=0;
19546 1238 tile+=24;
19547 1238 break;
19548
19549 case l_down: //dl
19550 1146 flip=0;
19551 1146 tile+=28;
19552 1146 break;
19553
19554 case r_down: //dr
19555 1180 flip=0;
19556 1180 tile+=32;
19557 1180 break;
19558 }
19559
19560 9580 tile += ((clk&6)>>1);
19561 9580 }
19562 else
19563 {
19564 tile += (clk&4)?1:0;
19565 }
19566
19567
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
19568 8608 enemy::draw(dest);
19569 9580 }
19570
19571
19572 /**********************************/
19573 /********** Misc Code ***********/
19574 /**********************************/
19575
19576 148769 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
19577 {
19578
4/6
✓ Branch 0 taken 116927 times.
✓ Branch 1 taken 31842 times.
✓ Branch 2 taken 116927 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116927 times.
✗ Branch 5 not taken.
148769 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
19579
4/8
✓ Branch 0 taken 148769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 148769 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 148769 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 148769 times.
✗ Branch 7 not taken.
148769 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
19580
1/2
✓ Branch 0 taken 148769 times.
✗ Branch 1 not taken.
148769 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
19581 148769 }
19582
19583 29171 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
19584 {
19585 // Kludge
19586
4/8
✓ Branch 0 taken 29171 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 29171 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 29171 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29171 times.
✗ Branch 7 not taken.
29171 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
19587 29171 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
19588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29171 times.
29171 delete w;
19589 29171 return ret;
19590 }
19591
19592 3055 void enemy_scored(int32_t index)
19593 {
19594 3055 ((enemy*)guys.spr(index))->scored=true;
19595 3055 }
19596
19597 975 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy)
19598 {
19599
7/12
✓ Branch 0 taken 975 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 975 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 975 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 975 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✓ Branch 9 taken 860 times.
✓ Branch 10 taken 975 times.
✗ Branch 11 not taken.
975 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_bit(quest_rules,qr_NOGUYPOOF)?0:clk,mainguy);
19600 975 guys.add(g);
19601 975 }
19602
19603 21784 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19604 {
19605
5/10
✓ Branch 0 taken 21784 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21784 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 21784 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 21784 times.
✗ Branch 9 not taken.
21784 item *i = new item(zfix(x), zfix(y - get_bit(quest_rules, qr_NOITEMOFFSET)), zfix(0), id, pickup, 0);
19606 21784 items.add(i);
19607 21784 }
19608
19609 60 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
19610 {
19611
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
60 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
19612 60 items.add(i);
19613 60 }
19614
19615 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
19616 {
19617 item *i = new item((zfix)x,(zfix)y-(get_bit(quest_rules, qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
19618 items.add(i);
19619 }
19620
19621 54 void kill_em_all()
19622 {
19623
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 54 times.
304 for(int32_t i=0; i<guys.Count(); i++)
19624 {
19625 250 enemy *e = ((enemy*)guys.spr(i));
19626
19627
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 225 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
250 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19628
19629 225 e->kickbucket();
19630 225 }
19631 54 }
19632
19633 bool can_kill_em_all()
19634 {
19635 for(int32_t i=0; i<guys.Count(); i++)
19636 {
19637 enemy *e = ((enemy*)guys.spr(i));
19638
19639 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
19640 if(e->superman) continue;
19641 return true;
19642 }
19643 return false;
19644 }
19645
19646 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
19647 // For Hero's hit detection. Don't count them if they are stunned or are guys.
19648 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19649 {
19650 for(int32_t i=0; i<guys.Count(); i++)
19651 {
19652 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19653 {
19654 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_bit(quest_rules, qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
19655 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
19656 {
19657 return i;
19658 }
19659 }
19660 }
19661
19662 return -1;
19663 }
19664
19665 4757937 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19666 {
19667
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4757937 times.
✓ Branch 2 taken 14171298 times.
✓ Branch 3 taken 4746877 times.
18918175 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
19668 {
19669
2/2
✓ Branch 0 taken 11060 times.
✓ Branch 1 taken 14160238 times.
14171298 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
19670 {
19671 11060 return i;
19672 }
19673 14160238 }
19674
19675 4746877 return -1;
19676 4757937 }
19677
19678 // For Hero's hit detection. Count them if they are dying.
19679 21301 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
19680 {
19681 21301 enemy *e = (enemy*)guys.spr(index);
19682
3/4
✓ Branch 0 taken 21301 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12034 times.
✓ Branch 3 taken 9267 times.
21301 if(!e || e->hp > 0)
19683 12034 return -1;
19684
19685 9267 bool d = e->dying;
19686 9267 int32_t hc = e->hclk;
19687 9267 e->dying = false;
19688 9267 e->hclk = 0;
19689 9267 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
19690 9267 e->dying = d;
19691 9267 e->hclk = hc;
19692
19693
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 9201 times.
9267 return hit ? index : -1;
19694 21301 }
19695
19696 5165833 bool hasMainGuy()
19697 {
19698
2/2
✓ Branch 0 taken 6636797 times.
✓ Branch 1 taken 1902894 times.
8539691 for(int32_t i=0; i<guys.Count(); i++)
19699 {
19700
2/2
✓ Branch 0 taken 3262939 times.
✓ Branch 1 taken 3373858 times.
6636797 if(((enemy*)guys.spr(i))->mainguy)
19701 {
19702 3262939 return true;
19703 }
19704 3373858 }
19705
19706 1902894 return false;
19707 5165833 }
19708
19709 47 void EatHero(int32_t index)
19710 {
19711 47 ((eStalfos*)guys.spr(index))->eathero();
19712 47 }
19713
19714 3 void GrabHero(int32_t index)
19715 {
19716 3 ((eWallM*)guys.spr(index))->grabhero();
19717 3 }
19718
19719 292 bool CarryHero()
19720 {
19721
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
19722 {
19723
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
19724 {
19725
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
19726 {
19727 292 Hero.x=guys.spr(i)->x;
19728 292 Hero.y=guys.spr(i)->y;
19729 292 return ((eWallM*)guys.spr(i))->misc > 0;
19730 }
19731 63 }
19732
19733 // Like Likes currently can't carry Hero.
19734 /*
19735 if(((guy*)(guys.spr(i)))->family==eeLIKE)
19736 {
19737 if(((eLikeLike*)guys.spr(i))->hashero)
19738 {
19739 Hero.x=guys.spr(i)->x;
19740 Hero.y=guys.spr(i)->y;
19741 return (true);
19742 }
19743 }*/
19744 599 }
19745
19746 return false;
19747 292 }
19748
19749 // Move item with guy
19750 void movefairy(zfix &x,zfix &y,int32_t misc)
19751 {
19752 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19753
19754 if(i!=-1)
19755 {
19756 x = guys.spr(i)->x;
19757 y = guys.spr(i)->y;
19758 }
19759 }
19760
19761 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19762 void movefairy2(zfix x,zfix y,int32_t misc)
19763 {
19764 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19765
19766 if(i!=-1)
19767 {
19768 guys.spr(i)->x = x;
19769 guys.spr(i)->y = y;
19770 }
19771 }// Move item with guy
19772
19773 26588 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
19774 {
19775 26588 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19776
19777
1/2
✓ Branch 0 taken 26588 times.
✗ Branch 1 not taken.
26588 if(fairy)
19778 {
19779 26588 x = fairy->x;
19780 26588 y = fairy->y;
19781 26588 }
19782 26588 }
19783
19784 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
19785 void movefairynew2(zfix x,zfix y, item const &itemfairy)
19786 {
19787 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19788
19789 if(fairy)
19790 {
19791 fairy->x = x;
19792 fairy->y = y;
19793 }
19794 }
19795
19796 void killfairy(int32_t misc)
19797 {
19798 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
19799 guys.del(i);
19800 }
19801
19802 int32_t getGuyIndex(const int32_t eid)
19803 {
19804 for(word i = 0; i < guys.Count(); i++)
19805 {
19806 if(guys.spr(i)->getUID() == eid)
19807 return i;
19808 }
19809
19810 return -1;
19811 }
19812
19813 void killfairynew(item const &itemfairy)
19814 {
19815 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
19816 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
19817 }
19818
19819 //Should probably change this to return an 'enemy*', null on failure -Em
19820 9475 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
19821 {
19822 9475 return addenemy(x,y,0,id,clk);
19823 }
19824
19825 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
19826 {
19827 868 return addchild(x,y,0,id,clk, parent_scriptUID);
19828 }
19829
19830 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
19831 {
19832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
19833
19834 893 int32_t ret = 0;
19835 893 sprite *e=NULL;
19836 893 al_trace("Adding child\n");
19837
19838
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
19839 {
19840 //Fixme: possible enemy memory leak. (minor)
19841 case eeWALK:
19842
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
19843 16 break;
19844
19845 case eeLEV:
19846 e = new eLeever((zfix)x,(zfix)y,id,clk);
19847 break;
19848
19849 case eeTEK:
19850 e = new eTektite((zfix)x,(zfix)y,id,clk);
19851 break;
19852
19853 case eePEAHAT:
19854 e = new ePeahat((zfix)x,(zfix)y,id,clk);
19855 break;
19856
19857 case eeZORA:
19858 e = new eZora((zfix)x,(zfix)y,id,clk);
19859 break;
19860
19861 case eeGHINI:
19862 e = new eGhini((zfix)x,(zfix)y,id,clk);
19863 break;
19864
19865 case eeKEESE:
19866
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
19867 857 break;
19868
19869 case eeWIZZ:
19870
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
19871 15 break;
19872
19873 case eePROJECTILE:
19874 e = new eProjectile((zfix)x,(zfix)y,id,clk);
19875 break;
19876
19877 case eeWALLM:
19878 e = new eWallM((zfix)x,(zfix)y,id,clk);
19879 break;
19880
19881 case eeAQUA:
19882 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
19883 break;
19884
19885 case eeMOLD:
19886 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19887 break;
19888
19889 case eeMANHAN:
19890
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
19891 1 break;
19892
19893 case eeGLEEOK:
19894 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
19895 break;
19896
19897 case eeGHOMA:
19898 e = new eGohma((zfix)x,(zfix)y,id,clk);
19899 break;
19900
19901 case eeLANM:
19902 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
19903 break;
19904
19905 case eeGANON:
19906 e = new eGanon((zfix)x,(zfix)y,id,clk);
19907 break;
19908
19909 case eeFAIRY:
19910 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
19911 break;
19912
19913 case eeFIRE:
19914 e = new eFire((zfix)x,(zfix)y,id,clk);
19915 break;
19916
19917 case eeOTHER:
19918 e = new eOther((zfix)x,(zfix)y,id,clk);
19919 break;
19920
19921
19922 case eeSCRIPT01:
19923 case eeSCRIPT02:
19924 case eeSCRIPT03:
19925 case eeSCRIPT04:
19926 case eeSCRIPT05:
19927 case eeSCRIPT06:
19928 case eeSCRIPT07:
19929 case eeSCRIPT08:
19930 case eeSCRIPT09:
19931 case eeSCRIPT10:
19932 case eeSCRIPT11:
19933 case eeSCRIPT12:
19934 case eeSCRIPT13:
19935 case eeSCRIPT14:
19936 case eeSCRIPT15:
19937 case eeSCRIPT16:
19938 case eeSCRIPT17:
19939 case eeSCRIPT18:
19940 case eeSCRIPT19:
19941 case eeSCRIPT20:
19942 {
19943 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19944 {
19945 e = new eScript((zfix)x,(zfix)y,id,clk);
19946 break;
19947 }
19948 else return 0;
19949 }
19950
19951 case eeFFRIENDLY01:
19952 case eeFFRIENDLY02:
19953 case eeFFRIENDLY03:
19954 case eeFFRIENDLY04:
19955 case eeFFRIENDLY05:
19956 case eeFFRIENDLY06:
19957 case eeFFRIENDLY07:
19958 case eeFFRIENDLY08:
19959 case eeFFRIENDLY09:
19960 case eeFFRIENDLY10:
19961 {
19962 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
19963 {
19964 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
19965 }
19966 else return 0;
19967
19968 }
19969
19970 case eeSPINTILE:
19971 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
19972 break;
19973
19974 // and these enemies use the misc10/misc2 value
19975 case eeROCK:
19976 {
19977 switch(guysbuf[id&0xFFF].misc10)
19978 {
19979 case 1:
19980 e = new eBoulder((zfix)x,(zfix)y,id,clk);
19981 break;
19982
19983 case 0:
19984 default:
19985 e = new eRock((zfix)x,(zfix)y,id,clk);
19986 break;
19987 }
19988
19989 break;
19990 }
19991
19992 case eeTRAP:
19993 {
19994 switch(guysbuf[id&0xFFF].misc2)
19995 {
19996 case 1:
19997 e = new eTrap2((zfix)x,(zfix)y,id,clk);
19998 break;
19999
20000 case 0:
20001 default:
20002 e = new eTrap((zfix)x,(zfix)y,id,clk);
20003 break;
20004 }
20005
20006 break;
20007 }
20008
20009 case eeDONGO:
20010 {
20011 switch(guysbuf[id&0xFFF].misc10)
20012 {
20013 case 1:
20014 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20015 break;
20016
20017 case 0:
20018 default:
20019 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20020 break;
20021 }
20022
20023 break;
20024 }
20025
20026 case eeDIG:
20027 {
20028
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
20029 {
20030 case 1:
20031 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20032 break;
20033
20034 4 case 0:
20035 default:
20036
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20037 4 break;
20038 }
20039
20040 4 break;
20041 }
20042
20043 case eePATRA:
20044 {
20045 switch(guysbuf[id&0xFFF].misc10)
20046 {
20047 case 1:
20048 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20049 {
20050 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20051 break;
20052 }
20053 [[fallthrough]];
20054 case 0:
20055 default:
20056 e = new ePatra((zfix)x,(zfix)y,id,clk);
20057 break;
20058 }
20059
20060 break;
20061 }
20062
20063 case eeGUY:
20064 {
20065 switch(guysbuf[id&0xFFF].misc10)
20066 {
20067 case 1:
20068 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20069 break;
20070
20071 case 0:
20072 default:
20073 e = new eNPC((zfix)x,(zfix)y,id,clk);
20074 break;
20075 }
20076
20077 break;
20078 }
20079
20080 case eeNONE:
20081 if(guysbuf[id&0xFFF].misc10 ==1)
20082 {
20083 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20084 break;
20085 break;
20086 }
20087 [[fallthrough]];
20088 default:
20089
20090 return 0;
20091 }
20092
20093 893 ret++; // Made one enemy.
20094
20095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
20096 {
20097 e->z = (zfix)z;
20098 }
20099
20100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 ((enemy*)e)->ceiling = (z && canfall(id));
20101 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
20102 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
20103 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
20104 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20105 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
20106
20107
20108
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
20109 {
20110 return 0;
20111 }
20112
20113 // add segments of segmented enemies
20114 893 int32_t c=0;
20115
20116
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
20117 {
20118 case eeMOLD:
20119 {
20120 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20121 id &= 0xFFF;
20122
20123 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20124 {
20125 //christ this is messy -DD
20126 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20127
20128 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20129 {
20130 al_trace("Moldorm segment %d could not be created!\n",i+1);
20131
20132 for(int32_t j=0; j<i+1; j++)
20133 guys.del(guys.Count()-1);
20134
20135 return 0;
20136 }
20137
20138 if(i>0)
20139 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20140
20141 ret++;
20142 }
20143
20144 break;
20145 }
20146
20147 case eeLANM:
20148 {
20149 id &= 0xFFF;
20150 int32_t shft = guysbuf[id].misc2;
20151 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20152
20153 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20154 {
20155 al_trace("Lanmola segment 1 could not be created!\n");
20156 guys.del(guys.Count()-1);
20157 return 0;
20158 }
20159
20160 ret++;
20161
20162 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20163 {
20164 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20165 {
20166 al_trace("Lanmola segment %d could not be created!\n",i+1);
20167
20168 for(int32_t j=0; j<i+1; j++)
20169 guys.del(guys.Count()-1);
20170
20171 return 0;
20172 }
20173
20174 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20175 ret++;
20176 }
20177 }
20178 break;
20179
20180 case eeMANHAN:
20181 1 id &= 0xFFF;
20182
20183
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20184 {
20185
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20186 {
20187 al_trace("Manhandla head %d could not be created!\n",i+1);
20188
20189 for(int32_t j=0; j<i+1; j++)
20190 {
20191 guys.del(guys.Count()-1);
20192 }
20193
20194 return 0;
20195 }
20196
20197 4 ret++;
20198 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20199 4 }
20200
20201 1 break;
20202
20203 case eeGLEEOK:
20204 {
20205 id &= 0xFFF;
20206
20207 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20208 {
20209 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20210 {
20211 al_trace("Gleeok head %d could not be created!\n",i+1);
20212
20213 for(int32_t j=0; j<i+1; j++)
20214 {
20215 guys.del(guys.Count()-1);
20216 }
20217
20218 return false;
20219 }
20220
20221 c-=guysbuf[id].misc4;
20222 ret++;
20223 }
20224 }
20225 break;
20226
20227
20228 case eePATRA:
20229 {
20230 id &= 0xFFF;
20231 int32_t outeyes = 0;
20232
20233 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20234 {
20235 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20236 {
20237 al_trace("Patra outer eye %d could not be created!\n",i+1);
20238
20239 for(int32_t j=0; j<i+1; j++)
20240 guys.del(guys.Count()-1);
20241
20242 return 0;
20243 }
20244 else
20245 outeyes++;
20246
20247 ret++;
20248 }
20249
20250 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20251 {
20252 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20253 {
20254 al_trace("Patra inner eye %d could not be created!\n",i+1);
20255
20256 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20257 guys.del(guys.Count()-1);
20258
20259 return 0;
20260 }
20261
20262 ret++;
20263 }
20264
20265 break;
20266 }
20267 }
20268
20269 893 return ret;
20270 893 }
20271
20272 // Returns number of enemies/segments created
20273 33345 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
20274 {
20275 //zprint2("addenemy id is: %d\n", (id&0xFFF));
20276 33345 int32_t realid = id&0xFFF;
20277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33345 times.
33345 if( realid > MAXGUYS )
20278 {
20279 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
20280 return 0;
20281 }
20282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33345 times.
33345 if(id <= 0) return 0;
20283
20284 33345 int32_t ret = 0;
20285 33345 sprite *e=NULL;
20286
20287
26/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16941 times.
✓ Branch 4 taken 1097 times.
✓ Branch 5 taken 2000 times.
✓ Branch 6 taken 743 times.
✓ Branch 7 taken 1371 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 3625 times.
✓ Branch 10 taken 1647 times.
✓ Branch 11 taken 2019 times.
✓ Branch 12 taken 377 times.
✓ Branch 13 taken 63 times.
✓ Branch 14 taken 78 times.
✓ Branch 15 taken 53 times.
✓ Branch 16 taken 79 times.
✓ Branch 17 taken 44 times.
✓ Branch 18 taken 90 times.
✓ Branch 19 taken 6 times.
✓ Branch 20 taken 303 times.
✓ Branch 21 taken 75 times.
✓ Branch 22 taken 1278 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 196 times.
✓ Branch 25 taken 665 times.
✓ Branch 26 taken 113 times.
✓ Branch 27 taken 211 times.
✓ Branch 28 taken 48 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
33345 switch(guysbuf[id&0xFFF].family)
20288 {
20289 //Fixme: possible enemy memory leak. (minor)
20290 case eeWALK:
20291
3/6
✓ Branch 0 taken 16941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16941 times.
✗ Branch 5 not taken.
16941 e = new eStalfos((zfix)x,(zfix)y,id,clk);
20292 16941 break;
20293
20294 case eeLEV:
20295
3/6
✓ Branch 0 taken 1097 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1097 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1097 times.
✗ Branch 5 not taken.
1097 e = new eLeever((zfix)x,(zfix)y,id,clk);
20296 1097 break;
20297
20298 case eeTEK:
20299
3/6
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2000 times.
✗ Branch 5 not taken.
2000 e = new eTektite((zfix)x,(zfix)y,id,clk);
20300 2000 break;
20301
20302 case eePEAHAT:
20303
3/6
✓ Branch 0 taken 743 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 743 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 743 times.
✗ Branch 5 not taken.
743 e = new ePeahat((zfix)x,(zfix)y,id,clk);
20304 743 break;
20305
20306 case eeZORA:
20307
3/6
✓ Branch 0 taken 1371 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1371 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1371 times.
✗ Branch 5 not taken.
1371 e = new eZora((zfix)x,(zfix)y,id,clk);
20308 1371 break;
20309
20310 case eeGHINI:
20311
3/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
129 e = new eGhini((zfix)x,(zfix)y,id,clk);
20312 129 break;
20313
20314 case eeKEESE:
20315
3/6
✓ Branch 0 taken 3625 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3625 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3625 times.
✗ Branch 5 not taken.
3625 e = new eKeese((zfix)x,(zfix)y,id,clk);
20316 3625 break;
20317
20318 case eeWIZZ:
20319
3/6
✓ Branch 0 taken 1647 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1647 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1647 times.
✗ Branch 5 not taken.
1647 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
20320 1647 break;
20321
20322 case eePROJECTILE:
20323
3/6
✓ Branch 0 taken 2019 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2019 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2019 times.
✗ Branch 5 not taken.
2019 e = new eProjectile((zfix)x,(zfix)y,id,clk);
20324 2019 break;
20325
20326 case eeWALLM:
20327
3/6
✓ Branch 0 taken 377 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 377 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 377 times.
✗ Branch 5 not taken.
377 e = new eWallM((zfix)x,(zfix)y,id,clk);
20328 377 break;
20329
20330 case eeAQUA:
20331
3/6
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 63 times.
✗ Branch 5 not taken.
63 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
20332 63 break;
20333
20334 case eeMOLD:
20335
6/12
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 78 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 78 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 78 times.
✓ Branch 10 taken 78 times.
✗ Branch 11 not taken.
78 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20336 78 break;
20337
20338 case eeMANHAN:
20339
3/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
53 e = new eManhandla((zfix)x,(zfix)y,id,clk);
20340 53 break;
20341
20342 case eeGLEEOK:
20343
6/12
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 79 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 79 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 79 times.
✗ Branch 11 not taken.
79 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
20344 79 break;
20345
20346 case eeGHOMA:
20347
3/6
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44 times.
✗ Branch 5 not taken.
44 e = new eGohma((zfix)x,(zfix)y,id,clk);
20348 44 break;
20349
20350 case eeLANM:
20351
6/12
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 90 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 90 times.
✓ Branch 10 taken 90 times.
✗ Branch 11 not taken.
90 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
20352 90 break;
20353
20354 case eeGANON:
20355
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 e = new eGanon((zfix)x,(zfix)y,id,clk);
20356 6 break;
20357
20358 case eeFAIRY:
20359
3/6
✓ Branch 0 taken 303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 303 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 303 times.
✗ Branch 5 not taken.
303 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
20360 303 break;
20361
20362 case eeFIRE:
20363
3/6
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✗ Branch 5 not taken.
75 e = new eFire((zfix)x,(zfix)y,id,clk);
20364 75 break;
20365
20366 case eeOTHER:
20367
3/6
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1278 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1278 times.
✗ Branch 5 not taken.
1278 e = new eOther((zfix)x,(zfix)y,id,clk);
20368 1278 break;
20369
20370
20371 case eeSCRIPT01:
20372 case eeSCRIPT02:
20373 case eeSCRIPT03:
20374 case eeSCRIPT04:
20375 case eeSCRIPT05:
20376 case eeSCRIPT06:
20377 case eeSCRIPT07:
20378 case eeSCRIPT08:
20379 case eeSCRIPT09:
20380 case eeSCRIPT10:
20381 case eeSCRIPT11:
20382 case eeSCRIPT12:
20383 case eeSCRIPT13:
20384 case eeSCRIPT14:
20385 case eeSCRIPT15:
20386 case eeSCRIPT16:
20387 case eeSCRIPT17:
20388 case eeSCRIPT18:
20389 case eeSCRIPT19:
20390 case eeSCRIPT20:
20391 {
20392 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20393 {
20394 e = new eScript((zfix)x,(zfix)y,id,clk);
20395 break;
20396 }
20397 else return 0;
20398 }
20399
20400 case eeFFRIENDLY01:
20401 case eeFFRIENDLY02:
20402 case eeFFRIENDLY03:
20403 case eeFFRIENDLY04:
20404 case eeFFRIENDLY05:
20405 case eeFFRIENDLY06:
20406 case eeFFRIENDLY07:
20407 case eeFFRIENDLY08:
20408 case eeFFRIENDLY09:
20409 case eeFFRIENDLY10:
20410 {
20411 if ( !get_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
20412 {
20413 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
20414 }
20415 else return 0;
20416
20417 }
20418
20419 case eeSPINTILE:
20420
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
20421 94 break;
20422
20423 // and these enemies use the misc10/misc2 value
20424 case eeROCK:
20425 {
20426
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 166 times.
196 switch(guysbuf[id&0xFFF].misc10)
20427 {
20428 case 1:
20429
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
20430 30 break;
20431
20432 166 case 0:
20433 default:
20434
3/6
✓ Branch 0 taken 166 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 166 times.
✗ Branch 5 not taken.
166 e = new eRock((zfix)x,(zfix)y,id,clk);
20435 166 break;
20436 }
20437
20438 196 break;
20439 }
20440
20441 case eeTRAP:
20442 {
20443
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 119 times.
✓ Branch 2 taken 546 times.
665 switch(guysbuf[id&0xFFF].misc2)
20444 {
20445 case 1:
20446
3/6
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✗ Branch 5 not taken.
119 e = new eTrap2((zfix)x,(zfix)y,id,clk);
20447 119 break;
20448
20449 546 case 0:
20450 default:
20451
3/6
✓ Branch 0 taken 546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 546 times.
✗ Branch 5 not taken.
546 e = new eTrap((zfix)x,(zfix)y,id,clk);
20452 546 break;
20453 }
20454
20455 665 break;
20456 }
20457
20458 case eeDONGO:
20459 {
20460
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 111 times.
113 switch(guysbuf[id&0xFFF].misc10)
20461 {
20462 case 1:
20463
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
20464 2 break;
20465
20466 111 case 0:
20467 default:
20468
3/6
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
111 e = new eDodongo((zfix)x,(zfix)y,id,clk);
20469 111 break;
20470 }
20471
20472 113 break;
20473 }
20474
20475 case eeDIG:
20476 {
20477
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
✓ Branch 2 taken 34 times.
211 switch(guysbuf[id&0xFFF].misc10)
20478 {
20479 case 1:
20480
3/6
✓ Branch 0 taken 177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 177 times.
✗ Branch 5 not taken.
177 e = new eLilDig((zfix)x,(zfix)y,id,clk);
20481 177 break;
20482
20483 34 case 0:
20484 default:
20485
3/6
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
34 e = new eBigDig((zfix)x,(zfix)y,id,clk);
20486 34 break;
20487 }
20488
20489 211 break;
20490 }
20491
20492 case eePATRA:
20493 {
20494
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 3 times.
48 switch(guysbuf[id&0xFFF].misc10)
20495 {
20496 case 1:
20497
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_bit(quest_rules,qr_HARDCODED_BS_PATRA))
20498 {
20499
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
20500 3 break;
20501 }
20502 [[fallthrough]];
20503 45 case 0:
20504 default:
20505
3/6
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 45 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
45 e = new ePatra((zfix)x,(zfix)y,id,clk);
20506 45 break;
20507 }
20508
20509 48 break;
20510 }
20511
20512 case eeGUY:
20513 {
20514 switch(guysbuf[id&0xFFF].misc10)
20515 {
20516 case 1:
20517 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20518 break;
20519
20520 case 0:
20521 default:
20522 e = new eNPC((zfix)x,(zfix)y,id,clk);
20523 break;
20524 }
20525
20526 break;
20527 }
20528
20529 case eeNONE:
20530 if(guysbuf[id&0xFFF].misc10 ==1)
20531 {
20532 e = new eTrigger((zfix)x,(zfix)y,id,clk);
20533 break;
20534 break;
20535 }
20536 [[fallthrough]];
20537 default:
20538
20539 return 0;
20540 }
20541
20542 33345 ret++; // Made one enemy.
20543
20544
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 33262 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
33345 if(z && canfall(id))
20545 {
20546 59 e->z = (zfix)z;
20547 59 }
20548
20549
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 33262 times.
33345 ((enemy*)e)->ceiling = (z && canfall(id));
20550
20551
1/2
✓ Branch 0 taken 33345 times.
✗ Branch 1 not taken.
33345 if(!guys.add(e))
20552 {
20553 return 0;
20554 }
20555
20556 // add segments of segmented enemies
20557 33345 int32_t c=0;
20558
20559
6/6
✓ Branch 0 taken 32997 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 79 times.
✓ Branch 5 taken 48 times.
33345 switch(guysbuf[id&0xFFF].family)
20560 {
20561 case eeMOLD:
20562 {
20563 78 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20564 78 id &= 0xFFF;
20565
20566
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 528 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 528 times.
✓ Branch 6 taken 450 times.
✓ Branch 7 taken 78 times.
528 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
20567 {
20568 //christ this is messy -DD
20569 450 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
20570
20571
4/8
✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 450 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 450 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 450 times.
✗ Branch 7 not taken.
450 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
20572 {
20573 al_trace("Moldorm segment %d could not be created!\n",i+1);
20574
20575 for(int32_t j=0; j<i+1; j++)
20576 guys.del(guys.Count()-1);
20577
20578 return 0;
20579 }
20580
20581
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 372 times.
450 if(i>0)
20582 372 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20583
20584 450 ret++;
20585 450 }
20586
20587 78 break;
20588 }
20589
20590 case eeLANM:
20591 {
20592 90 id &= 0xFFF;
20593 90 int32_t shft = guysbuf[id].misc2;
20594 90 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
20595
20596
4/8
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 90 times.
✗ Branch 7 not taken.
90 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
20597 {
20598 al_trace("Lanmola segment 1 could not be created!\n");
20599 guys.del(guys.Count()-1);
20600 return 0;
20601 }
20602
20603 90 ret++;
20604
20605
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 505 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 505 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 505 times.
✓ Branch 6 taken 415 times.
✓ Branch 7 taken 90 times.
505 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
20606 {
20607
4/8
✓ Branch 0 taken 415 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 415 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 415 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 415 times.
✗ Branch 7 not taken.
415 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
20608 {
20609 al_trace("Lanmola segment %d could not be created!\n",i+1);
20610
20611 for(int32_t j=0; j<i+1; j++)
20612 guys.del(guys.Count()-1);
20613
20614 return 0;
20615 }
20616
20617 415 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
20618 415 ret++;
20619 415 }
20620 }
20621 90 break;
20622
20623 case eeMANHAN:
20624 53 id &= 0xFFF;
20625
20626
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 53 times.
297 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
20627 {
20628
4/8
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 244 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 244 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 244 times.
✗ Branch 7 not taken.
244 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
20629 {
20630 al_trace("Manhandla head %d could not be created!\n",i+1);
20631
20632 for(int32_t j=0; j<i+1; j++)
20633 {
20634 guys.del(guys.Count()-1);
20635 }
20636
20637 return 0;
20638 }
20639
20640 244 ret++;
20641 244 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
20642 244 }
20643
20644 53 break;
20645
20646 case eeGLEEOK:
20647 {
20648 79 id &= 0xFFF;
20649
20650
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 309 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 309 times.
✓ Branch 6 taken 230 times.
✓ Branch 7 taken 79 times.
309 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
20651 {
20652
4/8
✓ Branch 0 taken 230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 230 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 230 times.
✗ Branch 7 not taken.
230 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
20653 {
20654 al_trace("Gleeok head %d could not be created!\n",i+1);
20655
20656 for(int32_t j=0; j<i+1; j++)
20657 {
20658 guys.del(guys.Count()-1);
20659 }
20660
20661 return false;
20662 }
20663
20664 230 c-=guysbuf[id].misc4;
20665 230 ret++;
20666 230 }
20667 }
20668 79 break;
20669
20670
20671 case eePATRA:
20672 {
20673 48 id &= 0xFFF;
20674 48 int32_t outeyes = 0;
20675
20676
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 378 times.
✓ Branch 3 taken 48 times.
426 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
20677 {
20678
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 360 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 360 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 360 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 360 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
378 if(!((guysbuf[id].misc10&&get_bit(quest_rules,qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
20679 {
20680 al_trace("Patra outer eye %d could not be created!\n",i+1);
20681
20682 for(int32_t j=0; j<i+1; j++)
20683 guys.del(guys.Count()-1);
20684
20685 return 0;
20686 }
20687 else
20688 378 outeyes++;
20689
20690 378 ret++;
20691 378 }
20692
20693
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 48 times.
136 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
20694 {
20695
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
20696 {
20697 al_trace("Patra inner eye %d could not be created!\n",i+1);
20698
20699 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
20700 guys.del(guys.Count()-1);
20701
20702 return 0;
20703 }
20704
20705 88 ret++;
20706 88 }
20707
20708 48 break;
20709 }
20710 }
20711
20712 33345 return ret;
20713 33345 }
20714
20715 737179 bool isjumper(int32_t id)
20716 {
20717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 737179 times.
737179 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20718 {
20719 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
20720 return false;
20721 }
20722
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 652187 times.
✓ Branch 2 taken 84988 times.
737179 switch(guysbuf[id&0xFFF].family)
20723 {
20724 case eeROCK:
20725 case eeTEK:
20726 4 return true;
20727
20728 case eeWALK:
20729
3/4
✓ Branch 0 taken 84988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 72723 times.
84988 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
20730 72723 }
20731
20732 724910 return false;
20733 737179 }
20734
20735
20736 95002 bool isfixedtogrid(int32_t id)
20737 {
20738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95002 times.
95002 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20739 {
20740 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
20741 return false;
20742 }
20743
1/2
✓ Branch 0 taken 95002 times.
✗ Branch 1 not taken.
95002 switch(guysbuf[id&0xFFF].family)
20744 {
20745 case eeWALK:
20746 case eeLEV:
20747 case eeZORA:
20748 case eeDONGO:
20749 case eeGANON:
20750 case eeROCK:
20751 case eeGLEEOK:
20752 case eeAQUA:
20753 case eeLANM:
20754 return true;
20755 }
20756
20757 95002 return false;
20758 95002 }
20759
20760 // Can't fall, can have Z value.
20761 23614825 bool isflier(int32_t id)
20762 {
20763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23614825 times.
23614825 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20764 {
20765 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
20766 return false;
20767 }
20768
2/2
✓ Branch 0 taken 21025309 times.
✓ Branch 1 taken 2589516 times.
23614825 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
20769 {
20770 case eePEAHAT:
20771 case eeKEESE:
20772 case eePATRA:
20773 case eeFAIRY:
20774 case eeGHINI:
20775
20776 // Could theoretically have their Z set by a script
20777 case eeFIRE:
20778 2589516 return true;
20779 break;
20780 }
20781
20782 21025309 return false;
20783 23614825 }
20784
20785 // Can't have Z position
20786 1194470 bool never_in_air(int32_t id)
20787 {
20788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1194470 times.
1194470 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20789 {
20790 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
20791 return false;
20792 }
20793
2/2
✓ Branch 0 taken 1187148 times.
✓ Branch 1 taken 7322 times.
1194470 switch(guysbuf[id&0xFFF].family)
20794 {
20795 case eeMANHAN:
20796 case eeMOLD:
20797 case eeLANM:
20798 case eeGLEEOK:
20799 case eeZORA:
20800 case eeLEV:
20801 case eeAQUA:
20802 case eeROCK:
20803 case eeGANON:
20804 case eeTRAP:
20805 case eePROJECTILE:
20806 case eeSPINTILE:
20807 7322 return true;
20808 }
20809
20810 1187148 return false;
20811 1194470 }
20812
20813 816006 bool canfall(int32_t id)
20814 {
20815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 816006 times.
816006 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20816 {
20817 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
20818 return false;
20819 }
20820
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 815984 times.
✓ Branch 2 taken 22 times.
816006 switch(guysbuf[id&0xFFF].family)
20821 {
20822 case eeGUY:
20823 {
20824
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if(id < eOCTO1S)
20825 22 return false;
20826
20827 switch(guysbuf[id&0xFFF].misc10)
20828 {
20829 case 1:
20830 case 2:
20831 return true;
20832
20833 case 0:
20834 case 3:
20835 default:
20836 return false;
20837 }
20838
20839 case eeGHOMA:
20840 case eeDIG:
20841 return false;
20842 }
20843 }
20844
20845
20846
4/4
✓ Branch 0 taken 808662 times.
✓ Branch 1 taken 7322 times.
✓ Branch 2 taken 71483 times.
✓ Branch 3 taken 737179 times.
815984 return !never_in_air(id) && !isflier(id) && !isjumper(id);
20847 816006 }
20848
20849 22710262 bool enemy::enemycanfall(int32_t id, bool checkgrav)
20850 {
20851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22710262 times.
22710262 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
20852 {
20853 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
20854 return false;
20855 }
20856 //Z_scripterrlog("canfall family is %d:\n", family);
20857 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
20858 //if ( family == eeFIRE && id >= eSTART )
20859 //{
20860 // Z_scripterrlog("eeFire\n");
20861 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
20862 //}
20863
20864 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
20865
20866
3/3
✓ Branch 0 taken 167290 times.
✓ Branch 1 taken 21964403 times.
✓ Branch 2 taken 578569 times.
22710262 switch(guysbuf[id&0xFFF].family)
20867 {
20868 case eeGUY:
20869 {
20870
1/2
✓ Branch 0 taken 578569 times.
✗ Branch 1 not taken.
578569 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
20871 578569 return false;
20872
20873 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
20874 {
20875 case 1:
20876 case 2:
20877 return true;
20878
20879 case 0:
20880 case 3:
20881 default:
20882 return false;
20883 }
20884
20885 case eeGHOMA:
20886 case eeDIG:
20887 167290 return false;
20888 }
20889 }
20890
20891
2/2
✓ Branch 0 taken 16208393 times.
✓ Branch 1 taken 5756010 times.
21964403 if(!checkgrav) return true;
20892 16208393 return (moveflags & FLAG_OBEYS_GRAV);
20893
20894 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
20895 // {
20896 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
20897 // else return false;
20898 // }
20899 // else
20900 // {
20901 // return (moveflags & FLAG_OBEYS_GRAV);
20902 // }
20903 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
20904 22710262 }
20905
20906 477 void addfires()
20907 {
20908
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 233 times.
477 if(!get_bit(quest_rules,qr_NOGUYFIRES))
20909 {
20910 244 int32_t bs = get_bit(quest_rules,qr_BSZELDA);
20911 244 addguy(bs? 64: 72,64,gFIRE,-17,false);
20912 244 addguy(bs?176:168,64,gFIRE,-18,false);
20913 244 }
20914 477 }
20915
20916 10418 void loadguys()
20917 {
20918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10418 times.
10418 if(loaded_guys)
20919 return;
20920
20921 10418 loaded_guys=true;
20922
20923 10418 byte Guy=0;
20924 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
20925 // Else use mITEM and ipONETIME
20926 10418 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
20927 10418 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
20928
20929 10418 repaircharge=0;
20930 10418 adjustmagic=false;
20931 10418 learnslash=false;
20932
20933
2/2
✓ Branch 0 taken 31260 times.
✓ Branch 1 taken 10418 times.
41678 for(int32_t i=0; i<3; i++)
20934 {
20935 31260 prices[i]=0;
20936 31260 }
20937
20938 10418 hasitem=0;
20939
20940
4/4
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 9826 times.
✓ Branch 2 taken 314 times.
✓ Branch 3 taken 278 times.
10418 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
20941 {
20942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278 times.
278 if(DMaps[currdmap].flags&dmfCAVES)
20943 {
20944 278 Guy=tmpscr[1].guy;
20945 278 }
20946 278 }
20947 else
20948 {
20949 10140 Guy=tmpscr->guy;
20950
20951
4/4
✓ Branch 0 taken 9828 times.
✓ Branch 1 taken 312 times.
✓ Branch 2 taken 6000 times.
✓ Branch 3 taken 3828 times.
10140 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
20952 3828 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
20953 }
20954
20955 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
20956
4/4
✓ Branch 0 taken 2258 times.
✓ Branch 1 taken 8160 times.
✓ Branch 2 taken 1768 times.
✓ Branch 3 taken 490 times.
10418 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
20957 {
20958
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 484 times.
490 if(tmpscr->room==rZELDA)
20959 {
20960 6 addguy(120,72,Guy,-15,true);
20961 6 guys.spr(0)->hxofs=1000;
20962 6 addenemy(128,96,eFIRE,-15);
20963 6 addenemy(112,96,eFIRE,-15);
20964 6 addenemy(96,120,eFIRE,-15);
20965 6 addenemy(144,120,eFIRE,-15);
20966 6 return;
20967 }
20968
20969
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 475 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 2 times.
484 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
20970 477 addfires();
20971
20972
2/2
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 274 times.
488 if(currscr>=128)
20973
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 267 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
281 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
20974 7 Guy=0;
20975
20976
3/6
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 392 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 22 times.
488 switch(tmpscr->room)
20977 {
20978 case rSP_ITEM:
20979 case rGRUMBLE:
20980 case rBOMBS:
20981 case rARROWS:
20982 case rSWINDLE:
20983 case rMUPGRADE:
20984 case rLEARNSLASH:
20985 case rTAKEONE:
20986
8/8
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
74 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
20987 25 Guy=0;
20988
20989 114 break;
20990
20991 case rREPAIR:
20992 if (get_bit(quest_rules, qr_OLD_DOORREPAIR)) break;
20993 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
20994 Guy=0;
20995
20996 break;
20997 case rRP_HC:
20998 if (get_bit(quest_rules, qr_OLD_POTION_OR_HC)) break;
20999 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21000 Guy=0;
21001
21002 break;
21003 case rMONEY:
21004 if (get_bit(quest_rules, qr_OLD_SECRETMONEY)) break;
21005 if((get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)
21006 Guy=0;
21007
21008 break;
21009
21010 case rTRIFORCE:
21011 {
21012 22 int32_t tc = TriforceCount();
21013
21014
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 11 times.
22 if(get_bit(quest_rules,qr_4TRI))
21015 {
21016
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_bit(quest_rules,qr_3TRI) && tc>=3) || tc>=4)
21017 10 Guy=0;
21018 9 }
21019 else
21020 {
21021
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
11 if((get_bit(quest_rules,qr_3TRI) && tc>=6) || tc>=8)
21022 11 Guy=0;
21023 }
21024 }
21025 20 break;
21026 }
21027
21028
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 435 times.
486 if(Guy)
21029 {
21030
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 426 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
435 if(Guy!=gFAIRY || !get_bit(quest_rules,qr_NOFAIRYGUYFIRES))
21031 426 blockpath=true;
21032
21033
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 168 times.
435 if(currscr<128)
21034 168 sfx(WAV_SCALE);
21035
21036
4/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 165 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 267 times.
435 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true);
21037 435 Hero.Freeze();
21038 435 }
21039 486 }
21040
2/2
✓ Branch 0 taken 9882 times.
✓ Branch 1 taken 46 times.
9928 else if(Guy==gFAIRY) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
21041 {
21042 46 sfx(WAV_SCALE);
21043 46 addguy(120,62,gFAIRY,-14,false);
21044 46 }
21045
21046 10414 loaditem();
21047
21048 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
21049 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
21050
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 10406 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6 times.
10414 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
21051 {
21052 //setmapflag();
21053
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 6 times.
66 for(int32_t i=0; i<10; i++)
21054 60 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
21055 6 }
21056 10420 }
21057
21058 10420 void loaditem()
21059 {
21060 10420 byte Item = 0;
21061
21062
2/2
✓ Branch 0 taken 9828 times.
✓ Branch 1 taken 592 times.
10420 if(currscr<128)
21063 {
21064 9828 Item=tmpscr->item;
21065
21066
4/4
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 9340 times.
✓ Branch 2 taken 8884 times.
✓ Branch 3 taken 944 times.
9828 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21067 {
21068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 944 times.
944 if(tmpscr->flags8&fSECRETITEM)
21069 hasitem=8;
21070
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 469 times.
944 else if(tmpscr->flags&fITEM)
21071 475 hasitem=1;
21072
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 448 times.
469 else if(tmpscr->enemyflags&efCARRYITEM)
21073 21 hasitem=4; // Will be set to 2 by roaming_item
21074 else
21075
2/4
✓ Branch 0 taken 448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 448 times.
✗ Branch 3 not taken.
896 items.add(new item((zfix)tmpscr->itemx,
21076
7/14
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 445 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 448 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 448 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 448 times.
✗ Branch 13 not taken.
448 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21077
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 445 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 445 times.
✗ Branch 9 not taken.
448 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21078
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 405 times.
448 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
21079 448 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21080 944 }
21081 9828 }
21082
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 314 times.
592 else if(!(DMaps[currdmap].flags&dmfCAVES))
21083 {
21084
4/6
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 310 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
315 if((!getmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
21085
4/4
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 108 times.
314 && (currscr==128 || !get_bit(quest_rules,qr_ITEMSINPASSAGEWAYS)))
21086 {
21087 109 Item=tmpscr[1].catchall;
21088
21089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if(Item)
21090
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
218 items.add(new item((zfix)tmpscr->itemx,
21091
4/14
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 109 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 109 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 109 times.
✗ Branch 13 not taken.
109 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_bit(quest_rules, qr_NOITEMOFFSET)?0:1),
21092
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 109 times.
✗ Branch 9 not taken.
109 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
21093 109 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
21094 109 }
21095 314 }
21096 10420 }
21097
21098 446 void never_return(int32_t index)
21099 {
21100
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 74 times.
446 if(!get_bit(quest_rules,qr_KILLALL))
21101 74 goto doit;
21102
21103
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 178 times.
1434 for(int32_t i=0; i<guys.Count(); i++)
21104
4/4
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 787 times.
✓ Branch 2 taken 194 times.
✓ Branch 3 taken 275 times.
1256 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
21105 {
21106 194 goto dontdoit;
21107 178 }
21108
21109 doit:
21110 252 setmapflag(mNEVERRET);
21111 dontdoit:
21112 446 return;
21113 }
21114
21115 22658 bool slowguy(int32_t id)
21116 {
21117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22658 times.
22658 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21118 {
21119 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
21120 return false;
21121 }
21122 //return (guysbuf[id].step<100);
21123
2/2
✓ Branch 0 taken 19386 times.
✓ Branch 1 taken 3272 times.
22658 switch(id)
21124 {
21125 case eOCTO1S:
21126 case eOCTO2S:
21127 case eOCTO1F:
21128 case eOCTO2F:
21129 case eLEV1:
21130 case eLEV2:
21131 case eROCK:
21132 case eBOULDER:
21133 3272 return true;
21134 }
21135
21136 19386 return false;
21137 22658 }
21138
21139 25796 bool ok2add(int32_t id)
21140 {
21141
2/4
✓ Branch 0 taken 25796 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25796 times.
25796 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
21142 {
21143 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
21144 return false;
21145 }
21146
4/4
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 25452 times.
✓ Branch 2 taken 158 times.
✓ Branch 3 taken 186 times.
25796 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
21147 186 return false;
21148
21149
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25500 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 78 times.
25610 switch(guysbuf[id].family)
21150 {
21151 // I added a special case for shooters because having traps on the same screen
21152 // was preventing them from spawning due to TMPNORET. This means they will
21153 // never stay dead, though, so it may not be the best solution. - Saf
21154 case eePROJECTILE:
21155 32 return true;
21156
21157
21158 case eeDIG:
21159 {
21160
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 33 times.
78 switch(guysbuf[id].misc10)
21161 {
21162 case 1:
21163
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_bit(quest_rules,qr_NOTMPNORET))
21164 13 return !getmapflag(mTMPNORET);
21165
21166 32 return true;
21167
21168 33 case 0:
21169 default:
21170 33 return true;
21171 }
21172 }
21173 case eeGANON:
21174 case eeTRAP:
21175 if ((guysbuf[id].family == eeGANON && !get_bit(quest_rules, qr_CAN_PLACE_GANON))
21176 || (guysbuf[id].family == eeTRAP && !get_bit(quest_rules, qr_CAN_PLACE_TRAPS))) return false;
21177 [[fallthrough]];
21178 default:
21179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25500 times.
25500 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
21180 25500 break;
21181 }
21182
21183
2/2
✓ Branch 0 taken 8758 times.
✓ Branch 1 taken 16742 times.
25500 if(!get_bit(quest_rules,qr_NOTMPNORET))
21184 16742 return !getmapflag(mTMPNORET);
21185
21186 8758 return true;
21187 25796 }
21188
21189 224297 void activate_fireball_statue(int32_t pos)
21190 {
21191
3/4
✓ Branch 0 taken 93017 times.
✓ Branch 1 taken 131280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93017 times.
224297 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
21192 {
21193 131280 return;
21194 }
21195
21196 93017 int32_t cx=-1000, cy=-1000;
21197 93017 int32_t x = (pos&15)<<4;
21198 93017 int32_t y = pos&0xF0;
21199
21200 93017 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21201
21202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93017 times.
93017 if(!isfixedtogrid(statueID))
21203 {
21204
2/2
✓ Branch 0 taken 939 times.
✓ Branch 1 taken 92078 times.
93017 if(ctype==cL_STATUE)
21205 {
21206 939 cx=x+4;
21207 939 cy=y+7;
21208 939 }
21209
2/2
✓ Branch 0 taken 966 times.
✓ Branch 1 taken 91112 times.
92078 else if(ctype==cR_STATUE)
21210 {
21211 966 cx=x-8;
21212 966 cy=y-1;
21213 966 }
21214
2/2
✓ Branch 0 taken 91032 times.
✓ Branch 1 taken 80 times.
91112 else if(ctype==cC_STATUE)
21215 {
21216 80 cx=x;
21217 80 cy=y;
21218 80 }
21219 93017 }
21220 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
21221 {
21222 cx=x;
21223 cy=y;
21224 }
21225
21226
2/2
✓ Branch 0 taken 91032 times.
✓ Branch 1 taken 1985 times.
93017 if(cx!=-1000) // No point creating it if this is false
21227 {
21228
2/2
✓ Branch 0 taken 6033 times.
✓ Branch 1 taken 1985 times.
8018 for(int32_t j=0; j<guys.Count(); j++)
21229 {
21230
3/4
✓ Branch 0 taken 1128 times.
✓ Branch 1 taken 4905 times.
✓ Branch 2 taken 1128 times.
✗ Branch 3 not taken.
6033 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
21231 {
21232 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
21233 return; // No point deleting it. A script might be toying with it in some way.
21234 else
21235 guys.del(j);
21236 }
21237 6033 }
21238
21239 1985 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
21240 1985 }
21241 224297 }
21242
21243 10370 void activate_fireball_statues()
21244 {
21245
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 9856 times.
10370 if(!(tmpscr->enemyflags&efFIREBALLS))
21246 {
21247 9856 return;
21248 }
21249
21250
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 90464 times.
90978 for(int32_t i=0; i<176; i++)
21251 {
21252 90464 activate_fireball_statue(i);
21253 90464 }
21254 10370 }
21255
21256 10370 void load_default_enemies()
21257 {
21258 10370 wallm_load_clk=frame-80;
21259 10370 int32_t Id=0;
21260
21261
2/2
✓ Branch 0 taken 9505 times.
✓ Branch 1 taken 865 times.
10370 if(tmpscr->enemyflags&efZORA)
21262 {
21263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(zoraID>=0)
21264 865 addenemy(-16, -16, zoraID, 0);
21265 865 }
21266
21267
2/2
✓ Branch 0 taken 10299 times.
✓ Branch 1 taken 71 times.
10370 if(tmpscr->enemyflags&efTRAP4)
21268 {
21269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(cornerTrapID>=0)
21270 {
21271 71 addenemy(32, 32, cornerTrapID, -14);
21272 71 addenemy(208, 32, cornerTrapID, -14);
21273 71 addenemy(32, 128, cornerTrapID, -14);
21274 71 addenemy(208, 128, cornerTrapID, -14);
21275 71 }
21276 71 }
21277
21278
2/2
✓ Branch 0 taken 114070 times.
✓ Branch 1 taken 10370 times.
124440 for(int32_t y=0; y<176; y+=16)
21279 {
21280
2/2
✓ Branch 0 taken 1825120 times.
✓ Branch 1 taken 114070 times.
1939190 for(int32_t x=0; x<256; x+=16)
21281 {
21282 1825120 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
21283 1825120 int32_t cflag = MAPFLAG(x, y);
21284 1825120 int32_t cflag_i = MAPCOMBOFLAG(x, y);
21285
21286
4/6
✓ Branch 0 taken 1825120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825069 times.
✓ Branch 3 taken 51 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1825069 times.
1825120 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
21287 {
21288
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 41 times.
51 if(trapLOSHorizontalID>=0)
21289 41 addenemy(x, y, trapLOSHorizontalID, -14);
21290 51 }
21291
4/6
✓ Branch 0 taken 1825069 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1825053 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1825053 times.
1825069 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
21292 {
21293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(trapLOSVerticalID>=0)
21294 16 addenemy(x, y, trapLOSVerticalID, -14);
21295 16 }
21296
4/6
✓ Branch 0 taken 1825053 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824914 times.
✓ Branch 3 taken 139 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1824914 times.
1825053 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
21297 {
21298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(trapLOS4WayID>=0)
21299 {
21300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(addenemy(x, y, trapLOS4WayID, -14))
21301 139 guys.spr(guys.Count()-1)->dummy_int[1]=2;
21302 139 }
21303 139 }
21304
21305
4/6
✓ Branch 0 taken 1824914 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824866 times.
✓ Branch 3 taken 48 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1824866 times.
1824914 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
21306 {
21307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(trapConstantHorizontalID>=0)
21308 48 addenemy(x, y, trapConstantHorizontalID, -14);
21309 48 }
21310
4/6
✓ Branch 0 taken 1824866 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1824795 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1824795 times.
1824866 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
21311 {
21312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 if(trapConstantVerticalID>=0)
21313 71 addenemy(x, y, trapConstantVerticalID, -14);
21314 71 }
21315
21316
1/2
✓ Branch 0 taken 1825120 times.
✗ Branch 1 not taken.
1825120 if(ctype==cSPINTILE1)
21317 {
21318 // Awaken spinning tile
21319 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
21320 }
21321 1825120 }
21322 114070 }
21323
21324
2/2
✓ Branch 0 taken 10335 times.
✓ Branch 1 taken 35 times.
10370 if(tmpscr->enemyflags&efTRAP2)
21325 {
21326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(centerTrapID>=-1)
21327 {
21328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(addenemy(64, 80, centerTrapID, -14))
21329 35 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21330
21331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(addenemy(176, 80, centerTrapID, -14))
21332 35 guys.spr(guys.Count()-1)->dummy_int[1]=1;
21333 35 }
21334 35 }
21335
21336
2/2
✓ Branch 0 taken 10323 times.
✓ Branch 1 taken 47 times.
10370 if(tmpscr->enemyflags&efROCKS)
21337 {
21338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(rockID>=0)
21339 {
21340 47 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21341 47 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21342 47 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
21343 47 }
21344 47 }
21345
21346 10370 activate_fireball_statues();
21347 10370 }
21348
21349 12916299 void update_slope_combopos(int32_t lyr, int32_t pos)
21350 {
21351
2/4
✓ Branch 0 taken 12916299 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12916299 times.
12916299 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
21352 12916299 mapscr* s = FFCore.tempScreens[lyr];
21353 12916299 newcombo const& cmb = combobuf[s->data[pos]];
21354
21355 12916299 auto id = (176*lyr)+pos;
21356 12916299 auto it = slopes.find(id);
21357
21358 12916299 bool wasSlope = it!=slopes.end();
21359 12916299 bool isSlope = cmb.type == cSLOPE;
21360
21361
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 12916229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
12916299 if(isSlope && !wasSlope)
21362 {
21363 70 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
21364 70 }
21365
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12916229 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12916229 else if(wasSlope && !isSlope)
21366 {
21367 slopes.erase(it);
21368 }
21369 12916299 }
21370 10426 void update_slope_comboposes()
21371 {
21372
2/2
✓ Branch 0 taken 72982 times.
✓ Branch 1 taken 10426 times.
83408 for(auto lyr = 0; lyr < 7; ++lyr)
21373 {
21374
2/2
✓ Branch 0 taken 12844832 times.
✓ Branch 1 taken 72982 times.
12917814 for(auto pos = 0; pos < 176; ++pos)
21375 12844832 update_slope_combopos(lyr,pos);
21376 72982 }
21377 10426 }
21378
21379 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
21380 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
21381 133833 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
21382 {
21383 133833 delete_fireball_shooter(s, pos);
21384 133833 }
21385
21386 //Placeholder in case we need it.
21387 void screen_ffc_modify_preroutine(word index)
21388 {
21389 return;
21390 }
21391
21392 // Everything that must be done after we change a screen's combo to another combo. -L
21393 133833 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
21394 {
21395 133833 s->valid |= mVALID;
21396 133833 activate_fireball_statue(pos);
21397
21398
2/2
✓ Branch 0 taken 133739 times.
✓ Branch 1 taken 94 times.
133833 if(combobuf[s->data[pos]].type==cSPINTILE1)
21399 {
21400 // Awaken spinning tile
21401 94 awaken_spinning_tile(s,pos);
21402 94 }
21403 133833 int32_t lyr = -1;
21404
2/2
✓ Branch 0 taken 87953 times.
✓ Branch 1 taken 45880 times.
133833 if(s == tmpscr) lyr = 0;
21405
2/2
✓ Branch 0 taken 62366 times.
✓ Branch 1 taken 468438 times.
530804 else for(size_t q = 0; q < 6; ++q)
21406 {
21407
2/2
✓ Branch 0 taken 25587 times.
✓ Branch 1 taken 442851 times.
468438 if(s == tmpscr2+q)
21408 {
21409 25587 lyr = q+1;
21410 25587 break;
21411 }
21412 442851 }
21413
2/2
✓ Branch 0 taken 62366 times.
✓ Branch 1 taken 71467 times.
133833 if(lyr > -1)
21414 71467 update_slope_combopos(lyr,pos);
21415 133833 }
21416
21417 2170809 void screen_ffc_modify_postroutine(word index)
21418 {
21419 2170809 ffcdata& ff = tmpscr->ffcs[index];
21420 2170809 newcombo const& cmb = combobuf[ff.getData()];
21421
21422 2170809 auto id = (176*7)+int32_t(index);
21423 2170809 auto it = slopes.find(id);
21424
21425 2170809 bool wasSlope = it!=slopes.end();
21426
2/2
✓ Branch 0 taken 2170707 times.
✓ Branch 1 taken 102 times.
2170809 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
21427
3/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 2170717 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 92 times.
2170809 if(isSlope && !wasSlope)
21428 {
21429 92 slopes.try_emplace(id, nullptr, &ff, id);
21430 92 }
21431
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2170716 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2170717 else if(wasSlope && !isSlope)
21432 {
21433 1 slopes.erase(it);
21434 1 }
21435
21436 2170809 tmpscr->ffcCountMarkDirty();
21437 2170809 }
21438
21439 void screen_combo_modify_pre(int32_t cid)
21440 {
21441 for(auto lyr = 0; lyr < 7; ++lyr)
21442 {
21443 mapscr* t = FFCore.tempScreens[lyr];
21444 for(int32_t i = 0; i < 176; i++)
21445 {
21446 if(t->data[i] == cid)
21447 {
21448 screen_combo_modify_preroutine(t,i);
21449 }
21450 }
21451 }
21452 }
21453 void screen_combo_modify_post(int32_t cid)
21454 {
21455 for(auto lyr = 0; lyr < 7; ++lyr)
21456 {
21457 mapscr* t = FFCore.tempScreens[lyr];
21458 for(int32_t i = 0; i < 176; i++)
21459 {
21460 if(t->data[i] == cid)
21461 {
21462 screen_combo_modify_postroutine(t,i);
21463 }
21464 }
21465 }
21466 for(word ind = 0; ind < MAXFFCS; ++ind)
21467 {
21468 if(tmpscr->ffcs[ind].getData() == cid)
21469 screen_ffc_modify_postroutine(ind);
21470 }
21471 }
21472
21473 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
21474 {
21475
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
21476 94 }
21477
21478
21479 // It stands for next_side_pos
21480 9789 void nsp(bool random)
21481 // moves sle_x and sle_y to the next position
21482 {
21483
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6528 times.
9789 if(random)
21484 {
21485
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
21486 {
21487 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
21488 1634 sle_y = (zc_oldrand()%10)*16;
21489 1634 }
21490 else
21491 {
21492 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
21493 1627 sle_x = (zc_oldrand()%15)*16;
21494 }
21495
21496 3261 return;
21497 }
21498
21499
2/2
✓ Branch 0 taken 4944 times.
✓ Branch 1 taken 1584 times.
6528 if(sle_x==0)
21500 {
21501
2/2
✓ Branch 0 taken 1442 times.
✓ Branch 1 taken 142 times.
1584 if(sle_y<160)
21502 1442 sle_y+=16;
21503 else
21504 142 sle_x+=16;
21505 1584 }
21506
2/2
✓ Branch 0 taken 2062 times.
✓ Branch 1 taken 2882 times.
4944 else if(sle_y==160)
21507 {
21508
2/2
✓ Branch 0 taken 1929 times.
✓ Branch 1 taken 133 times.
2062 if(sle_x<240)
21509 1929 sle_x+=16;
21510 else
21511 133 sle_y-=16;
21512 2062 }
21513
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 1632 times.
2882 else if(sle_x==240)
21514 {
21515
2/2
✓ Branch 0 taken 1130 times.
✓ Branch 1 taken 120 times.
1250 if(sle_y>0)
21516 1130 sle_y-=16;
21517 else
21518 120 sle_x-=16;
21519 1250 }
21520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1632 times.
1632 else if(sle_y==0)
21521 {
21522
1/2
✓ Branch 0 taken 1632 times.
✗ Branch 1 not taken.
1632 if(sle_x>0)
21523 1632 sle_x-=16;
21524 else
21525 sle_y+=16;
21526 1632 }
21527 9789 }
21528
21529 1844 int32_t next_side_pos(bool random)
21530 // moves sle_x and sle_y to the next available position
21531 // returns the direction the enemy should face
21532 {
21533 bool blocked;
21534 1844 int32_t c=0;
21535
21536 1844 do
21537 {
21538
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9664 times.
9789 nsp(c>35 ? false : random);
21539
3/4
✓ Branch 0 taken 1843 times.
✓ Branch 1 taken 7946 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1843 times.
11632 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
21540
1/2
✓ Branch 0 taken 1843 times.
✗ Branch 1 not taken.
1843 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
21541
2/4
✓ Branch 0 taken 1843 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1843 times.
✗ Branch 3 not taken.
1843 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
21542
2/4
✓ Branch 0 taken 1843 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1843 times.
1843 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
21543 1843 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
21544
21545
2/2
✓ Branch 0 taken 9788 times.
✓ Branch 1 taken 1 times.
9789 if(++c>50)
21546 1 return -1;
21547
2/2
✓ Branch 0 taken 7945 times.
✓ Branch 1 taken 1843 times.
9788 }
21548 9788 while(blocked);
21549
21550 1843 int32_t dir=0;
21551
21552
2/2
✓ Branch 0 taken 1302 times.
✓ Branch 1 taken 541 times.
1843 if(sle_x==0) dir=right;
21553
21554
2/2
✓ Branch 0 taken 1370 times.
✓ Branch 1 taken 473 times.
1843 if(sle_y==0) dir=down;
21555
21556
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 532 times.
1843 if(sle_x==240) dir=left;
21557
21558
1/2
✓ Branch 0 taken 1843 times.
✗ Branch 1 not taken.
1843 if(sle_y==168) dir=up;
21559
21560 1843 return dir;
21561 1844 }
21562
21563 bool can_side_load(int32_t id)
21564 {
21565 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
21566 {
21567 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
21568 return false;
21569 }
21570 switch(guysbuf[id].family) //id&0x0FFF)
21571 {
21572 //case eTEK1:
21573 //case eTEK2:
21574 //case eTEK3:
21575 //case eLEV1:
21576 //case eLEV2:
21577 //case eLEV3:
21578 //case eRAQUAM:
21579 //case eLAQUAM:
21580 //case eDODONGO:
21581 //case eMANHAN:
21582 //case eGLEEOK1:
21583 //case eGLEEOK2:
21584 //case eGLEEOK3:
21585 //case eGLEEOK4:
21586 //case eDIG1:
21587 //case eDIG3:
21588 //case eGOHMA1:
21589 //case eGOHMA2:
21590 //case eCENT1:
21591 //case eCENT2:
21592 //case ePATRA1:
21593 //case ePATRA2:
21594 //case eGANON:
21595 //case eMANHAN2:
21596 //case eCEILINGM: later
21597 //case eFLOORM: later
21598 //case ePATRABS:
21599 //case ePATRAL2:
21600 //case ePATRAL3:
21601 //case eGLEEOK1F:
21602 //case eGLEEOK2F:
21603 //case eGLEEOK3F:
21604 //case eGLEEOK4F:
21605 //case eDODONGOBS:
21606 //case eDODONGOF:
21607 //case eGOHMA3:
21608 //case eGOHMA4:
21609 //case eSHOOTMAGIC:
21610 //case eSHOOTROCK:
21611 //case eSHOOTSPEAR:
21612 //case eSHOOTSWORD:
21613 //case eSHOOTFLAME:
21614 //case eSHOOTFLAME2:
21615 //case eSHOOTFBALL:
21616 case eeTEK:
21617 case eeLEV:
21618 case eeAQUA:
21619 case eeDONGO:
21620 case eeMANHAN:
21621 case eeGLEEOK:
21622 case eeDIG:
21623 case eeGHOMA:
21624 case eeLANM:
21625 case eePATRA:
21626 case eeGANON:
21627 case eePROJECTILE:
21628 return false;
21629 break;
21630 }
21631
21632 return true;
21633 }
21634
21635 static bool script_sle = false;
21636 static int32_t sle_pattern = 0;
21637 void script_side_load_enemies()
21638 {
21639 if(script_sle || sle_clk) return;
21640 sle_cnt = 0;
21641 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21642 ++sle_cnt;
21643 script_sle = true;
21644 sle_pattern = tmpscr->pattern;
21645 sle_clk = 0;
21646 }
21647
21648 40988 void side_load_enemies()
21649 {
21650
3/4
✓ Branch 0 taken 40988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40430 times.
✓ Branch 3 taken 558 times.
40988 if(!script_sle && sle_clk==0)
21651 {
21652 558 sle_pattern = tmpscr->pattern;
21653 558 sle_cnt = 0;
21654 558 int32_t guycnt = 0;
21655 558 int16_t s = (currmap<<7)+currscr;
21656 558 bool beenhere=false;
21657 558 bool reload=true;
21658 558 bool unbeatablereload = true;
21659
21660 558 load_default_enemies();
21661
21662
2/2
✓ Branch 0 taken 3348 times.
✓ Branch 1 taken 558 times.
3906 for(int32_t i=0; i<6; i++)
21663
2/2
✓ Branch 0 taken 3181 times.
✓ Branch 1 taken 167 times.
3515 if(visited[i]==s)
21664 167 beenhere=true;
21665
21666
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 391 times.
558 if(!beenhere)
21667 {
21668 391 visited[vhead]=s;
21669 391 vhead = (vhead+1)%6;
21670 391 }
21671
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 39 times.
167 else if(game->guys[s]==0)
21672 {
21673 39 sle_cnt=0;
21674 39 reload=false;
21675 39 }
21676
21677
2/2
✓ Branch 0 taken 383 times.
✓ Branch 1 taken 175 times.
558 if(reload)
21678 {
21679 175 sle_cnt = game->guys[s];
21680
21681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 175 times.
175 if((get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
21682
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 175 times.
175 || sle_cnt==0)
21683 {
21684
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 970 times.
✓ Branch 2 taken 797 times.
✓ Branch 3 taken 175 times.
972 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21685 797 ++sle_cnt;
21686 175 }
21687
3/4
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 391 times.
519 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
21688 {
21689 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
21690 {
21691 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
21692 {
21693 unbeatablereload = false;
21694 }
21695 }
21696 if (unbeatablereload)
21697 {
21698 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21699 {
21700 ++sle_cnt;
21701 }
21702 }
21703 }
21704 519 }
21705
21706
4/4
✓ Branch 0 taken 558 times.
✓ Branch 1 taken 344 times.
✓ Branch 2 taken 344 times.
✓ Branch 3 taken 214 times.
902 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
21707 {
21708 688 sle_cnt = 0;
21709
21710
0/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
688 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
21711 ++sle_cnt;
21712 }
21713
21714
2/2
✓ Branch 0 taken 1805 times.
✓ Branch 1 taken 214 times.
2019 for(int32_t i=0; i<sle_cnt; i++)
21715 1805 ++guycnt;
21716
21717 214 game->guys[s] = guycnt;
21718 214 }
21719
21720
2/2
✓ Branch 0 taken 38800 times.
✓ Branch 1 taken 1844 times.
40644 if((++sle_clk+8)%24 == 0)
21721 {
21722 1844 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
21723
21724
4/4
✓ Branch 0 taken 1843 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 186 times.
✓ Branch 3 taken 1657 times.
1844 if(dir==-1 || tooclose(sle_x,sle_y,32))
21725 {
21726 187 return;
21727 }
21728
21729 1657 int32_t enemy_slot=guys.Count();
21730
21731
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1657 times.
1657 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
21732 sle_cnt--;
21733
21734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
1657 if(sle_cnt > 0)
21735 {
21736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
1657 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
21737 {
21738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1657 times.
1657 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
21739 {
21740 1657 guys.spr(enemy_slot)->dir = dir;
21741 1657 }
21742 1657 }
21743 1657 }
21744 1657 }
21745
21746
2/2
✓ Branch 0 taken 39964 times.
✓ Branch 1 taken 493 times.
40457 if(sle_cnt<=0)
21747 {
21748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 493 times.
493 if(script_sle)
21749 script_sle = false;
21750 493 else loaded_enemies=true;
21751 493 sle_clk = 0;
21752 493 }
21753 40644 }
21754
21755 1089148 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
21756 {
21757
21758
4/4
✓ Branch 0 taken 990346 times.
✓ Branch 1 taken 98802 times.
✓ Branch 2 taken 98802 times.
✓ Branch 3 taken 1089148 times.
1089148 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
21759 {
21760 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
21761 197604 return false; //never 0, never OoB.
21762 }
21763 // No corner enemies
21764
6/6
✓ Branch 0 taken 929967 times.
✓ Branch 1 taken 159181 times.
✓ Branch 2 taken 38423 times.
✓ Branch 3 taken 968390 times.
✓ Branch 4 taken 109780 times.
✓ Branch 5 taken 87824 times.
1089148 if((x==0 || x==240) && (y==0 || y==160))
21765
21766 197604 return false;
21767
21768 //Is a no spawn combo...
21769
3/4
✓ Branch 0 taken 968386 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 968386 times.
968390 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
21770 4 return false;
21771
21772 // No enemies in dungeon walls
21773
10/10
✓ Branch 0 taken 627393 times.
✓ Branch 1 taken 340993 times.
✓ Branch 2 taken 555873 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 484353 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 398529 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 312705 times.
968386 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
21774 314688 return false;
21775
21776 // Too close
21777
4/4
✓ Branch 0 taken 68466 times.
✓ Branch 1 taken 585232 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 68465 times.
653698 if(tooclose(x,y,40) && t<11)
21778 68465 return false;
21779
21780 // Can't fly onto it?
21781
4/4
✓ Branch 0 taken 113422 times.
✓ Branch 1 taken 471811 times.
✓ Branch 2 taken 33807 times.
✓ Branch 3 taken 16220 times.
635260 if(isflier(tmpscr->enemy[i])&&
21782
2/2
✓ Branch 0 taken 113413 times.
✓ Branch 1 taken 9 times.
113422 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
21783
2/2
✓ Branch 0 taken 50027 times.
✓ Branch 1 taken 63386 times.
113413 (_walkflag(x,y+8,2)&&!get_bit(quest_rules,qr_WALLFLIERS))))
21784 16229 return false;
21785
21786 // Can't jump onto it?
21787 if
21788 (
21789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83813 times.
652817 guysbuf[tmpscr->enemy[i]].family==eeTEK
21790
21791
2/2
✓ Branch 0 taken 83813 times.
✓ Branch 1 taken 485191 times.
569004 &&
21792 (
21793
1/2
✓ Branch 0 taken 83813 times.
✗ Branch 1 not taken.
83813 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
21794
1/2
✓ Branch 0 taken 83813 times.
✗ Branch 1 not taken.
83813 COMBOTYPE(x+8,y+8)==cNOENEMY||
21795
1/2
✓ Branch 0 taken 83813 times.
✗ Branch 1 not taken.
83813 ispitfall(x+8,y+8)||
21796
1/2
✓ Branch 0 taken 83813 times.
✗ Branch 1 not taken.
83813 MAPFLAG(x+8,y+8)==mfNOENEMY||
21797 83813 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
21798 )
21799 )
21800 {
21801 return false;
21802 }
21803
21804 // Other off-limit combos
21805
6/6
✓ Branch 0 taken 471811 times.
✓ Branch 1 taken 97193 times.
✓ Branch 2 taken 387998 times.
✓ Branch 3 taken 83813 times.
✓ Branch 4 taken 226567 times.
✓ Branch 5 taken 161431 times.
957002 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
21806
2/2
✓ Branch 0 taken 229849 times.
✓ Branch 1 taken 158149 times.
387998 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
21807 387998 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
21808 161431 return false;
21809
21810 // Don't ever generate enemies on these combos!
21811
3/4
✓ Branch 0 taken 407274 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 407274 times.
407573 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
21812 299 return false;
21813
21814 //BS Dodongos need at least 2 spaces.
21815
4/4
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 406338 times.
✓ Branch 2 taken 934 times.
✓ Branch 3 taken 2 times.
407274 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
21816 {
21817
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
21818 ((x>224)||_walkflag(x+16,y+8, 2))&&
21819 ((y<16) ||_walkflag(x, y-8, 2))&&
21820 ((y>144)||_walkflag(x, y+24,2)))
21821 {
21822 return false;
21823 }
21824 2 }
21825
21826 407274 return true;
21827 990346 }
21828
21829 47740 bool is_ceiling_pattern(int32_t i)
21830 {
21831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47740 times.
47740 return (i==pCEILING || i==pCEILINGR);
21832 }
21833
21834 5489 int32_t placeenemy(int32_t i)
21835 {
21836 5489 std::map<int32_t, int32_t> freeposcache;
21837 5489 int32_t frees = 0;
21838
21839
2/2
✓ Branch 0 taken 60379 times.
✓ Branch 1 taken 5489 times.
65868 for(int32_t y=0; y<176; y+=16)
21840 {
21841
2/2
✓ Branch 0 taken 966064 times.
✓ Branch 1 taken 60379 times.
1026443 for(int32_t x=0; x<256; x+=16)
21842 {
21843
3/4
✓ Branch 0 taken 966064 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 390104 times.
✓ Branch 3 taken 575960 times.
966064 if(is_starting_pos(i,x,y,0))
21844 {
21845
1/2
✓ Branch 0 taken 390104 times.
✗ Branch 1 not taken.
390104 freeposcache[frees++] = (y&0xF0)+(x>>4);
21846 390104 }
21847 966064 }
21848 60379 }
21849
21850
2/2
✓ Branch 0 taken 5488 times.
✓ Branch 1 taken 1 times.
5489 if(frees > 0)
21851
2/4
✓ Branch 0 taken 5488 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5488 times.
✗ Branch 3 not taken.
5488 return freeposcache[zc_oldrand()%frees];
21852
21853 1 return -1;
21854 5489 }
21855
21856 24140 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
21857 {
21858 24140 bool placed=false;
21859 24140 int32_t t=-1;
21860
21861 // First: enemy combo flags
21862
2/2
✓ Branch 0 taken 258297 times.
✓ Branch 1 taken 22659 times.
280956 for(int32_t sy=0; sy<176; sy+=16)
21863 {
21864
2/2
✓ Branch 0 taken 4121988 times.
✓ Branch 1 taken 256816 times.
4378804 for(int32_t sx=0; sx<256; sx+=16)
21865 {
21866 4121988 int32_t cflag = MAPFLAG(sx, sy);
21867 4121988 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
21868
21869
2/4
✓ Branch 0 taken 4121988 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4121988 times.
✗ Branch 3 not taken.
4121988 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
21870 {
21871 if(!ok2add(tmpscr->enemy[i]))
21872 {
21873 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21874 }
21875 else
21876 {
21877 addenemy(sx,
21878 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21879 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21880
21881 ++guycnt;
21882
21883 placed=true;
21884 goto placed_enemy;
21885 }
21886 }
21887
21888
4/4
✓ Branch 0 taken 4120507 times.
✓ Branch 1 taken 1481 times.
✓ Branch 2 taken 4120507 times.
✓ Branch 3 taken 1481 times.
4121988 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
21889 {
21890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1481 times.
1481 if(!ok2add(tmpscr->enemy[i]))
21891 {
21892 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21893 }
21894 else
21895 {
21896 2962 addenemy(sx,
21897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1481 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1481 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
21898
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1481 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1481 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
21899
21900 1481 ++guycnt;
21901
21902 1481 placed=true;
21903 1481 goto placed_enemy;
21904 }
21905 }
21906 4120507 }
21907 256816 }
21908
21909 // Next: enemy pattern
21910
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 17767 times.
✓ Branch 2 taken 17192 times.
✓ Branch 3 taken 5467 times.
✓ Branch 4 taken 17192 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 17192 times.
22659 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
21911 {
21912 17192 do
21913 {
21914
21915 // NES positions
21916 24304 pos%=9;
21917 24304 x=stx[loadside][pos];
21918 24304 y=sty[loadside][pos];
21919 24304 ++pos;
21920 24304 ++t;
21921
2/2
✓ Branch 0 taken 7112 times.
✓ Branch 1 taken 17192 times.
41496 }
21922
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 24282 times.
24304 while((t< 20) && !is_starting_pos(i,x,y,t));
21923 17192 }
21924
21925
4/4
✓ Branch 0 taken 17192 times.
✓ Branch 1 taken 5467 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 17170 times.
22659 if(t<0 || t >= 20) // above enemy pattern failed
21926 {
21927 // Final chance: find a random position anywhere onscreen
21928 5489 int32_t randpos = placeenemy(i);
21929
21930
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5488 times.
5489 if(randpos>-1)
21931 {
21932 5488 x=(randpos&15)<<4;
21933 5488 y= randpos&0xF0;
21934 5488 }
21935 else // All opportunities failed - abort
21936 {
21937 1 return;
21938 }
21939 5488 }
21940
21941 {
21942 22658 int32_t c=0;
21943 22658 c=clk;
21944
21945
2/2
✓ Branch 0 taken 3272 times.
✓ Branch 1 taken 19386 times.
22658 if(!slowguy(tmpscr->enemy[i]))
21946 19386 ++fastguys;
21947
2/2
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 2751 times.
3272 else if(fastguys>0)
21948 521 c=-15*(i-fastguys+2);
21949 else
21950 2751 c=-15*(i+1);
21951
21952
4/6
✓ Branch 0 taken 1059 times.
✓ Branch 1 taken 21599 times.
✓ Branch 2 taken 1059 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1059 times.
22658 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
21953 {
21954 // Special case for blue leevers
21955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1059 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1059 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
21956 c=-15*(i+1);
21957 else
21958 1059 c=-15;
21959 1059 }
21960
21961
2/2
✓ Branch 0 taken 22389 times.
✓ Branch 1 taken 269 times.
22658 if(!ok2add(tmpscr->enemy[i]))
21962 {
21963
4/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 231 times.
✓ Branch 2 taken 38 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 38 times.
269 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
21964 269 }
21965 else
21966 {
21967
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22389 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22389 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
21968 {
21969
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 22306 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
44778 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
21970
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 22306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
22389 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
21971
21972 22389 ++guycnt;
21973 22389 }
21974 }
21975
21976 22658 placed=true;
21977 22658 } // if(t < 20)
21978
21979 placed_enemy:
21980
21981 // I don't like this, but it seems to work...
21982 static bool foundCarrier;
21983
21984
2/2
✓ Branch 0 taken 18461 times.
✓ Branch 1 taken 5678 times.
24139 if(i==0)
21985 5678 foundCarrier=false;
21986
21987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24139 times.
24139 if(placed)
21988 {
21989
4/4
✓ Branch 0 taken 5678 times.
✓ Branch 1 taken 18461 times.
✓ Branch 2 taken 5539 times.
✓ Branch 3 taken 139 times.
24139 if(i==0 && tmpscr->enemyflags&efLEADER)
21990 {
21991 139 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
21992
21993
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 7 times.
139 if(index!=-1)
21994 {
21995 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
21996
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_bit(quest_rules, qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
21997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(index!=-1)
21998 {
21999 132 ((enemy*)guys.spr(index))->leader = true;
22000 132 }
22001 132 }
22002 139 }
22003
22004
4/4
✓ Branch 0 taken 24078 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 24057 times.
✓ Branch 3 taken 21 times.
24139 if(!foundCarrier && hasitem&(4|2))
22005 {
22006 21 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
22007
22008
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
22009 {
22010 21 ((enemy*)guys.spr(index))->itemguy = true;
22011 21 foundCarrier=true;
22012 21 }
22013 21 }
22014 24139 }
22015 24140 }
22016
22017 bool scriptloadenemies()
22018 {
22019 loaded_enemies = true;
22020 if(script_sle || sle_clk) return false;
22021 if(tmpscr->pattern==pNOSPAWN) return false;
22022
22023 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22024 {
22025 script_side_load_enemies();
22026 return true;
22027 }
22028
22029 int32_t pos=zc_oldrand()%9;
22030 int32_t clk=-15,x=0,y=0,fastguys=0;
22031 int32_t i=0,guycnt=0;
22032 int32_t loadcnt = 10;
22033
22034 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22035 {
22036 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22037
22038 --clk;
22039 }
22040 return true;
22041 }
22042
22043 5141578 void loadenemies()
22044 {
22045
3/4
✓ Branch 0 taken 5141578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40430 times.
✓ Branch 3 taken 5101148 times.
5141578 if(script_sle || sle_clk)
22046 {
22047 40430 side_load_enemies();
22048 40430 return;
22049 }
22050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5101148 times.
5101148 if(tmpscr->pattern==pNOSPAWN) return;
22051
2/2
✓ Branch 0 taken 5090760 times.
✓ Branch 1 taken 10388 times.
5101148 if(loaded_enemies)
22052 5090760 return;
22053
22054 // check if it's the dungeon boss and it has been beaten before
22055
4/4
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 10312 times.
✓ Branch 2 taken 58 times.
✓ Branch 3 taken 18 times.
10388 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
22056 {
22057 18 loaded_enemies = true;
22058 18 return;
22059 }
22060
22061
4/4
✓ Branch 0 taken 10053 times.
✓ Branch 1 taken 317 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 9812 times.
10370 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
22062 {
22063 558 side_load_enemies();
22064 558 return;
22065 }
22066
22067 9812 loaded_enemies=true;
22068
22069 // do enemies that are always loaded
22070 9812 load_default_enemies();
22071
22072 // dungeon basements
22073
22074 static byte dngn_enemy_x[4] = {32,96,144,208};
22075
22076
2/2
✓ Branch 0 taken 592 times.
✓ Branch 1 taken 9220 times.
9812 if(currscr>=128)
22077 {
22078
2/2
✓ Branch 0 taken 278 times.
✓ Branch 1 taken 314 times.
592 if(DMaps[currdmap].flags&dmfCAVES) return;
22079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
22080 {
22081 for(int32_t i=0; i<10; i++)
22082 {
22083 if ( tmpscr->enemy[i] )
22084 {
22085 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
22086 }
22087 }
22088 }
22089 else
22090 {
22091
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 314 times.
1570 for(int32_t i=0; i<4; i++)
22092
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 292 times.
1256 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
22093 }
22094 314 return;
22095 }
22096
22097 // check if it's been long enough to reload all enemies
22098
22099 9220 int32_t loadcnt = 10;
22100 9220 int16_t s = (currmap<<7)+currscr;
22101 9220 bool beenhere = false;
22102 9220 bool reload = true;
22103 9220 bool unbeatablereload = true;
22104
22105
2/2
✓ Branch 0 taken 55320 times.
✓ Branch 1 taken 9220 times.
64540 for(int32_t i=0; i<6; i++)
22106
2/2
✓ Branch 0 taken 52550 times.
✓ Branch 1 taken 2770 times.
58090 if(visited[i]==s)
22107 2770 beenhere = true;
22108
22109
2/2
✓ Branch 0 taken 2770 times.
✓ Branch 1 taken 6450 times.
9220 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
22110 {
22111 6450 visited[vhead]=s; //If not, it adds it to the array,
22112 6450 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
22113 6450 }
22114
2/2
✓ Branch 0 taken 1119 times.
✓ Branch 1 taken 1651 times.
2770 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
22115 {
22116 1651 loadcnt = 0; //It will tell it not to load any enemies,
22117 1651 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
22118 1651 }
22119
22120
2/2
✓ Branch 0 taken 1651 times.
✓ Branch 1 taken 7569 times.
9220 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
22121 {
22122 7569 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
22123
22124
2/4
✓ Branch 0 taken 2355 times.
✓ Branch 1 taken 5214 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7569 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
22125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2355 times.
2355 (get_bit(quest_rules, qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
22126 5214 loadcnt = 10; //That means all enemies need to be respawned.
22127
3/4
✓ Branch 0 taken 6450 times.
✓ Branch 1 taken 1119 times.
✓ Branch 2 taken 6450 times.
✗ Branch 3 not taken.
7569 if (!beenhere && get_bit(quest_rules, qr_UNBEATABLES_DONT_KEEP_DEAD))
22128 {
22129 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
22130 {
22131 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
22132 {
22133 unbeatablereload = false;
22134 }
22135 }
22136 if (unbeatablereload)
22137 {
22138 loadcnt = 10;
22139 }
22140 }
22141 7569 }
22142
22143
3/4
✓ Branch 0 taken 9220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 9174 times.
9220 if((get_bit(quest_rules,qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
22144 46 loadcnt = 10; //All enemies also need to be respawned.
22145
22146 9220 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
22147 9220 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in it's spawn poof.
22148 9220 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
22149
22150
4/4
✓ Branch 0 taken 4169 times.
✓ Branch 1 taken 29191 times.
✓ Branch 2 taken 24140 times.
✓ Branch 3 taken 9220 times.
33360 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
22151 {
22152 24140 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
22153
22154 24140 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
22155 24140 }
22156
22157 9220 game->guys[s] = guycnt;
22158 //} //if(true)
22159 5141578 }
22160 98 void moneysign()
22161 {
22162 98 additem(48,108,iRupy,ipDUMMY);
22163 // textout(scrollbuf,zfont,"X",64,112,CSET(0)+1);
22164 98 set_clip_state(pricesdisplaybuf, 0);
22165 98 textout_ex(pricesdisplaybuf,zfont,"X",64,112,CSET(0)+1,-1);
22166 98 }
22167
22168 685 void putprices(bool sign)
22169 {
22170
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 679 times.
685 if(fadeclk > 0) return;
22171 // refresh what's under the prices
22172 // for(int32_t i=5; i<12; i++)
22173 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
22174
22175 679 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
22176 679 int32_t step=32;
22177 679 int32_t x=80;
22178
22179
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 555 times.
679 if(prices[2]==0)
22180 {
22181 555 step<<=1;
22182
22183
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 20 times.
555 if(prices[1]==0)
22184 {
22185 535 x=112;
22186 535 }
22187 555 }
22188
22189
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 2037 times.
2716 for(int32_t i=0; i<3; i++)
22190 {
22191 // Kind of stupid, but it works: 100000 is used to indicate that an item
22192 // has a price of zero rather than there being no item.
22193 // 100000 isn't a valid price, so this doesn't cause problems.
22194
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 432 times.
2037 if(prices[i]!=0 && prices[i]<100000)
22195 {
22196 char buf[8];
22197 432 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
22198
22199 432 int32_t l=(int32_t)strlen(buf);
22200 432 set_clip_state(pricesdisplaybuf, 0);
22201
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 415 times.
432 textout_ex(pricesdisplaybuf,zfont,buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
22202 432 }
22203
22204 2037 x+=step;
22205 2037 }
22206 685 }
22207
22208 // Setting up special rooms
22209 // Also called when the Letter is used successfully.
22210 444 void setupscreen()
22211 {
22212 444 boughtsomething=false;
22213 444 int32_t t=currscr<128?0:1;
22214 444 word str=tmpscr[t].str;
22215
22216 // Prices are already set to 0 in dowarp()
22217
13/15
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 76 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 21 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
444 switch(tmpscr[t].room)
22218 {
22219 case rSP_ITEM: // special item
22220 76 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
22221 76 break;
22222
22223 case rINFO: // pay for info
22224 {
22225 8 int32_t count = 0;
22226 8 int32_t base = 88;
22227 8 int32_t step = 5;
22228
22229 8 moneysign();
22230
22231
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 24 times.
32 for(int32_t i=0; i<3; i++)
22232 {
22233
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(QMisc.info[tmpscr[t].catchall].str[i])
22234 {
22235 24 ++count;
22236 24 }
22237 else
22238 break;
22239 24 }
22240
22241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(count)
22242 {
22243
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(count==1)
22244 {
22245 base = 88+32;
22246 }
22247
22248
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(count==2)
22249 {
22250 step = 6;
22251 }
22252
22253
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 8 times.
32 for(int32_t i=0; i < count; i++)
22254 {
22255 24 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
22256 24 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22257 24 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
22258
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(prices[i]==0)
22259 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22260 24 int32_t itemid = current_item_id(itype_wealthmedal);
22261
22262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24 if(itemid>=0 && prices[i]!=100000)
22263 {
22264 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22265 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22266 else
22267 prices[i]-=itemsbuf[itemid].misc1;
22268 prices[i]=vbound(prices[i], -99999, 0);
22269 if(prices[i]==0)
22270 prices[i]=100000;
22271 }
22272
22273
2/6
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
22274 prices[i]=-1;
22275 24 }
22276 8 }
22277
22278 8 break;
22279 }
22280
22281 case rMONEY: // secret money
22282 35 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
22283 35 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22284 35 break;
22285
22286 case rGAMBLE: // gambling
22287 5 prices[0]=prices[1]=prices[2]=-10;
22288 5 moneysign();
22289 5 additem(88,89,iRupy,ipMONEY+ipDUMMY);
22290 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22291 5 additem(120,89,iRupy,ipMONEY+ipDUMMY);
22292 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22293 5 additem(152,89,iRupy,ipMONEY+ipDUMMY);
22294 5 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
22295 5 break;
22296
22297 case rREPAIR: // door repair
22298
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
22299 // }
22300 12 repaircharge=tmpscr[t].catchall;
22301 12 break;
22302
22303 case rMUPGRADE: // upgrade magic
22304 1 adjustmagic=true;
22305 1 break;
22306
22307 case rLEARNSLASH: // learn slash attack
22308 1 learnslash=true;
22309 1 break;
22310
22311 case rRP_HC: // heart container or red potion
22312 10 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
22313 10 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22314 10 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
22315 10 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22316 10 break;
22317
22318 case rP_SHOP: // potion shop
22319
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 17 times.
21 if(current_item(itype_letter)<i_letter_used)
22320 {
22321 4 str=0;
22322 4 break;
22323 }
22324
22325 [[fallthrough]];
22326 case rTAKEONE: // take one
22327 case rSHOP: // shop
22328 {
22329 86 int32_t count = 0;
22330 86 int32_t base = 88;
22331 86 int32_t step = 5;
22332
22333
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 85 times.
86 if(tmpscr[t].room != rTAKEONE)
22334 85 moneysign();
22335
22336 //count and align the stuff
22337
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 254 times.
329 for(int32_t i=0; i<3; ++i)
22338 {
22339
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 11 times.
254 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
22340 {
22341 243 ++count;
22342 243 }
22343 else
22344 {
22345 11 break;
22346 }
22347 243 }
22348
22349
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 4 times.
86 if(count==1)
22350 {
22351 4 base = 88+32;
22352 4 }
22353
22354
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 7 times.
86 if(count==2)
22355 {
22356 7 step = 6;
22357 7 }
22358
22359
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 86 times.
329 for(int32_t i=0; i<count; i++)
22360 {
22361 243 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
22362 243 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
22363
22364
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 241 times.
243 if(tmpscr[t].room != rTAKEONE)
22365 {
22366 241 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
22367
1/2
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
241 if(prices[i]==0)
22368 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22369 241 int32_t itemid = current_item_id(itype_wealthmedal);
22370
22371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 241 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
241 if(itemid>=0 && prices[i]!=100000)
22372 {
22373 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22374 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22375 else
22376 prices[i]+=itemsbuf[itemid].misc1;
22377 prices[i]=vbound(prices[i], 0, 99999);
22378 if(prices[i]==0)
22379 prices[i]=100000;
22380 }
22381
22382
2/4
✓ Branch 0 taken 241 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 241 times.
✗ Branch 3 not taken.
241 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
22383 prices[i]=1;
22384 241 }
22385 243 }
22386
22387 86 break;
22388 }
22389 case rBOTTLESHOP: // bottle shop
22390 {
22391 int32_t count = 0;
22392 int32_t base = 88;
22393 int32_t step = 5;
22394
22395 moneysign();
22396 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
22397 //count and align the stuff
22398 for(int32_t i=0; i<3; ++i)
22399 {
22400 if(bst.fill[count] != 0)
22401 {
22402 ++count;
22403 }
22404 else
22405 {
22406 break;
22407 }
22408 }
22409
22410 if(count==1)
22411 {
22412 base = 88+32;
22413 }
22414
22415 if(count==2)
22416 {
22417 step = 6;
22418 }
22419
22420 for(int32_t i=0; i<count; i++)
22421 {
22422 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
22423 //{ Setup dummy item
22424 item* curItem = ((item*)items.spr(items.Count()-1));
22425 curItem->PriceIndex = i;
22426 newcombo const& cmb = combobuf[bst.comb[i]];
22427 curItem->o_tile = cmb.o_tile;
22428 curItem->o_cset = bst.cset[i];
22429 curItem->cs = curItem->o_cset;
22430 curItem->tile = cmb.o_tile;
22431 curItem->o_speed = cmb.speed;
22432 curItem->o_delay = 0;
22433 curItem->frames = cmb.frames;
22434 curItem->flip = cmb.flip;
22435 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
22436 curItem->pstring = 0;
22437 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
22438 curItem->flash = false;
22439 curItem->twohand = false;
22440 curItem->anim = true;
22441 curItem->hxsz=1;
22442 curItem->hyofs=4;
22443 curItem->hysz=12;
22444 curItem->script=0;
22445 curItem->txsz=1;
22446 curItem->tysz=1;
22447 //}
22448
22449 prices[i] = bst.price[i];
22450 if(prices[i]==0)
22451 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
22452 int32_t itemid = current_item_id(itype_wealthmedal);
22453
22454 if(itemid>=0 && prices[i]!=100000)
22455 {
22456 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22457 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
22458 else
22459 prices[i]+=itemsbuf[itemid].misc1;
22460 prices[i]=vbound(prices[i], 0, 99999);
22461 if(prices[i]==0)
22462 prices[i]=100000;
22463 }
22464
22465 if((bst.price[i])>1 && prices[i]<1)
22466 prices[i]=1;
22467 }
22468
22469 break;
22470 }
22471
22472 case rBOMBS: // more bombs
22473 4 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22474 4 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22475 4 prices[0]=-tmpscr[t].catchall;
22476 4 break;
22477
22478 case rARROWS: // more arrows
22479 additem(120,89,iRupy,ipDUMMY+ipMONEY);
22480 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22481 prices[0]=-tmpscr[t].catchall;
22482 break;
22483
22484 case rSWINDLE: // leave heart container or money
22485 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
22486 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
22487 13 prices[0]=-1;
22488 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
22489 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
22490 13 prices[1]=-tmpscr[t].catchall;
22491 13 break;
22492
22493 }
22494
22495
3/4
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440 times.
444 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
22496 {
22497 4 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
22498 4 int32_t itemid = current_item_id(itype_wealthmedal);
22499
22500
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(itemid >= 0)
22501 {
22502 if(itemsbuf[itemid].flags & ITEM_FLAG1)
22503 prices[i]*=(itemsbuf[itemid].misc1/100.0);
22504 else
22505 prices[i]+=itemsbuf[itemid].misc1;
22506 }
22507
22508
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(tmpscr[t].catchall>1 && prices[i]>-1)
22509 prices[i]=-1;
22510 4 }
22511
22512 444 putprices(false);
22513
22514
2/2
✓ Branch 0 taken 421 times.
✓ Branch 1 taken 23 times.
444 if(str)
22515 {
22516 421 donewmsg(str);
22517 421 }
22518 else
22519 {
22520 23 Hero.unfreeze();
22521 }
22522 444 }
22523
22524 // Increments msgptr and returns the control code argument pointed at.
22525 630 word grab_next_argument()
22526 {
22527
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 630 times.
630 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
22528 630 byte val=MsgStrings[msgstr].s[++msgptr]-1;
22529 630 word ret=val;
22530
22531 // If an argument is succeeded by 255, then it's a three-byte argument -
22532 // between 254 and 65535 (or whatever the maximum actually is)
22533
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
22534
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
22535 {
22536 val=MsgStrings[msgstr].s[msgptr+2];
22537 word next=val;
22538 ret += 254*next;
22539 msgptr+=2;
22540 }
22541
22542 630 return ret;
22543 630 }
22544
22545 enum
22546 {
22547 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
22548 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
22549
22550 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
22551
22552 MNU_DATA_MAX
22553 };
22554 struct menu_choice
22555 {
22556 int32_t x, y;
22557 int32_t pos;
22558 int32_t upos, dpos, lpos, rpos;
22559 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
22560 {}
22561 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
22562 int32_t dpos, int32_t lpos, int32_t rpos)
22563 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
22564 {}
22565 };
22566 static int32_t msg_menu_data[MNU_DATA_MAX];
22567 static bool do_run_menu = false;
22568 bool do_end_str = false;
22569 static bool wait_advance = false;
22570 29 static std::map<int32_t, menu_choice> menu_options;
22571 11832 void clr_msg_data()
22572 {
22573 11832 do_end_str = false;
22574 11832 wait_advance = false;
22575 11832 do_run_menu = false;
22576 11832 menu_options.clear();
22577 11832 memset(msg_menu_data, 0, sizeof(msg_menu_data));
22578 11832 }
22579
22580 static bool doing_name_insert = false;
22581 static char namebuf[9] = {0};
22582 static char* nameptr = NULL;
22583 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
22584 bool runMenuCursor()
22585 {
22586 clear_bitmap(msg_menu_bmp_buf);
22587 if(!menu_options.size())
22588 {
22589 msg_menu_data[MNU_CHOSEN] = 0;
22590 return true; //end menu
22591 }
22592 int32_t pos = msg_menu_data[MNU_CHOSEN];
22593 //If the cursor is at an invalid pos, find the first pos >= 0...
22594 if(menu_options.find(pos) == menu_options.end())
22595 {
22596 pos = 0;
22597 while(menu_options.find(pos) == menu_options.end())
22598 ++pos;
22599 }
22600 menu_choice* ch = &menu_options[pos];
22601
22602 bool pressed = true;
22603 if(rUp()) pos = ch->upos;
22604 else if(rDown()) pos = ch->dpos;
22605 else if(rLeft()) pos = ch->lpos;
22606 else if(rRight()) pos = ch->rpos;
22607 else pressed = false;
22608
22609 if(pressed)
22610 msg_menu_data[MNU_TIMER] = 1;
22611
22612 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 5);
22613 bool held = false;
22614 if(hold_input)
22615 {
22616 held = true;
22617 if(Up()) pos = ch->upos;
22618 else if(Down()) pos = ch->dpos;
22619 else if(Left()) pos = ch->lpos;
22620 else if(Right()) pos = ch->rpos;
22621 else held = false;
22622 }
22623 //If the cursor is at an invalid pos, find the first pos >= 0...
22624 if(menu_options.find(pos) == menu_options.end())
22625 {
22626 pos = 0;
22627 while(menu_options.find(pos) == menu_options.end())
22628 ++pos;
22629 }
22630 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
22631 sfx(MsgStrings[msgstr].sfx);
22632
22633 ch = &menu_options[pos];
22634 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
22635 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
22636 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
22637 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
22638
22639 msg_menu_data[MNU_CHOSEN] = pos;
22640
22641 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
22642 {
22643 rAbtn(); //Eat
22644 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
22645 }
22646
22647 bool ret = (pressed || held) ? false : rAbtn();
22648 //Eat inputs
22649 rUp(); rDown(); rLeft(); rRight(); rAbtn();
22650
22651 if(ret)
22652 menu_options.clear();
22653
22654 return ret;
22655 //false if pos changed this frame; no confirming while moving the cursor!
22656 }
22657
22658 96906 bool bottom_margin_clip()
22659 {
22660 97206 return !get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)
22661
2/2
✓ Branch 0 taken 300 times.
✓ Branch 1 taken 96606 times.
96906 && cursor_y >= (msg_h + (get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
22662 }
22663
22664 42445 bool parsemsgcode()
22665 {
22666
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 42033 times.
42445 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
22667 42033 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
22668
4/36
✗ Branch 0 not taken.
✓ Branch 1 taken 41703 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 301 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
42033 switch(c)
22669 {
22670 case MSGC_NEWLINE:
22671 {
22672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22673 1 ssc_tile_hei = ssc_tile_hei_buf;
22674 1 ssc_tile_hei_buf = -1;
22675 1 cursor_y += thei + MsgStrings[msgstr].vspace;
22676 1 cursor_x=msg_margins[left];
22677 1 return true;
22678 }
22679
22680 case MSGC_COLOUR:
22681 {
22682 301 int32_t cset = (grab_next_argument());
22683 301 msgcolour = CSET(cset)+(grab_next_argument());
22684 301 return true;
22685 }
22686
22687 case MSGC_SHDCOLOR:
22688 {
22689 int32_t cset = (grab_next_argument());
22690 msg_shdcol = CSET(cset)+(grab_next_argument());
22691 return true;
22692 }
22693 case MSGC_SHDTYPE:
22694 {
22695 msg_shdtype = grab_next_argument();
22696 return true;
22697 }
22698
22699 case MSGC_SPEED:
22700 {
22701 28 msgspeed=grab_next_argument();
22702 28 return true;
22703 }
22704
22705 case MSGC_CTRUP:
22706 {
22707 int32_t a1 = grab_next_argument();
22708 int32_t a2 = grab_next_argument();
22709 game->change_counter(a2, a1);
22710 return true;
22711 }
22712
22713 case MSGC_CTRDN:
22714 {
22715 int32_t a1 = grab_next_argument();
22716 int32_t a2 = grab_next_argument();
22717 game->change_counter(-a2, a1);
22718 return true;
22719 }
22720
22721 case MSGC_CTRSET:
22722 {
22723 int32_t a1 = grab_next_argument();
22724 int32_t a2 = grab_next_argument();
22725 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
22726 return true;
22727 }
22728
22729 case MSGC_CTRUPPC:
22730 case MSGC_CTRDNPC:
22731 case MSGC_CTRSETPC:
22732 {
22733 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
22734 int32_t counter = grab_next_argument();
22735 int32_t amount = grab_next_argument();
22736 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
22737
22738 if(code==MSGC_CTRDNPC)
22739 amount*=-1;
22740
22741 if(code==MSGC_CTRSETPC)
22742 game->set_counter(amount, counter);
22743 else
22744 game->change_counter(amount, counter);
22745
22746 return true;
22747 }
22748
22749 case MSGC_GIVEITEM:
22750 {
22751 int32_t itemID = grab_next_argument();
22752
22753 getitem(itemID, true);
22754 if ( !item_doscript[itemID] && (((unsigned)itemID) < 256) )
22755 {
22756 itemScriptData[itemID].Clear();
22757 memset(item_stack[itemID], 0xFFFF, MAX_SCRIPT_REGISTERS * sizeof(int32_t));
22758 if ( (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) ) item_doscript[itemID] = 1;
22759 }
22760 return true;
22761 }
22762
22763
22764 case MSGC_WARP:
22765 {
22766 int32_t dmap = grab_next_argument();
22767 int32_t scrn = grab_next_argument();
22768 int32_t dx = grab_next_argument();
22769 int32_t dy = grab_next_argument();
22770 int32_t wfx = grab_next_argument();
22771 int32_t sfx = grab_next_argument();
22772 if(dx >= MAX_SCC_ARG) dx = -1;
22773 if(dy >= MAX_SCC_ARG) dy = -1;
22774 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
22775 return true;
22776 }
22777
22778 case MSGC_SETSCREEND:
22779 {
22780 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22781 int32_t screen = grab_next_argument();
22782 int32_t reg = grab_next_argument();
22783 int32_t val = grab_next_argument();
22784 FFCore.set_screen_d(screen + dmap, reg, val);
22785 return true;
22786 }
22787 case MSGC_TAKEITEM:
22788 {
22789 int32_t itemID = grab_next_argument();
22790 if ( item_doscript[itemID] )
22791 {
22792 item_doscript[itemID] = 4; //Val of 4 means 'clear stack and quit'
22793 }
22794 takeitem(itemID);
22795 if ( game->forced_bwpn == itemID )
22796 {
22797 game->forced_bwpn = -1;
22798 } //not else if! -Z
22799 if ( game->forced_awpn == itemID )
22800 {
22801 game->forced_awpn = -1;
22802 }
22803 if ( game->forced_xwpn == itemID )
22804 {
22805 game->forced_xwpn = -1;
22806 } //not else if! -Z
22807 if ( game->forced_ywpn == itemID )
22808 {
22809 game->forced_ywpn = -1;
22810 }
22811 verifyBothWeapons();
22812 return true;
22813 }
22814
22815 case MSGC_SFX:
22816 {
22817 sfx((int32_t)grab_next_argument(),128);
22818 return true;
22819 }
22820
22821 case MSGC_MIDI:
22822 {
22823 int32_t music = (int32_t)(grab_next_argument());
22824
22825 if(music==0)
22826 music_stop();
22827 else
22828 jukebox(music+(ZC_MIDI_COUNT-1));
22829
22830 return true;
22831 }
22832
22833 case MSGC_NAME:
22834 {
22835 doing_name_insert = true;
22836 sprintf(namebuf, "%s", game->get_name());
22837 nameptr = namebuf;
22838 return true;
22839 }
22840
22841 case MSGC_DRAWTILE:
22842 {
22843 int32_t tl = grab_next_argument();
22844 int32_t cs = grab_next_argument();
22845 int32_t t_wid = grab_next_argument();
22846 int32_t t_hei = grab_next_argument();
22847 int32_t fl = grab_next_argument();
22848
22849 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
22850 {
22851 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22852 ssc_tile_hei = ssc_tile_hei_buf;
22853 ssc_tile_hei_buf = -1;
22854 cursor_y += thei + MsgStrings[msgstr].vspace;
22855 if(bottom_margin_clip()) return true;
22856 cursor_x=msg_margins[left];
22857 }
22858
22859 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
22860 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
22861 cursor_x += MsgStrings[msgstr].hspace + t_wid;
22862 return true;
22863 }
22864
22865 case MSGC_GOTOIFRAND:
22866 {
22867 int32_t odds = (int32_t)(grab_next_argument());
22868
22869 if(!odds || !(zc_oldrand()%odds))
22870 goto switched;
22871
22872 (void)grab_next_argument();
22873 return true;
22874 }
22875
22876 case MSGC_GOTOIFGLOBAL:
22877 {
22878 int32_t arg = (int32_t)grab_next_argument();
22879 int32_t d = zc_min(7,arg);
22880 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
22881 arg = (int32_t)grab_next_argument();
22882
22883 if(game->screen_d[s][d] >= arg)
22884 goto switched;
22885
22886 (void)grab_next_argument();
22887 return true;
22888 }
22889
22890 case MSGC_CHANGEPORTRAIT:
22891 {
22892 return true; //not implemented
22893 }
22894
22895 case MSGC_GOTOIFCREEND:
22896 {
22897 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
22898 int32_t screen = grab_next_argument();
22899 int32_t reg = grab_next_argument();
22900 int32_t val = grab_next_argument();
22901 //int32_t nxtstr = grab_next_argument();
22902 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
22903 {
22904 goto switched;
22905 }
22906 (void)grab_next_argument();
22907 return true;
22908 }
22909
22910 case MSGC_GOTOIF:
22911 {
22912 int32_t it = (int32_t)grab_next_argument();
22913
22914 if(unsigned(it)<MAXITEMS && game->item[it])
22915 goto switched;
22916
22917 (void)grab_next_argument();
22918 return true;
22919 }
22920
22921 case MSGC_GOTOIFCTR:
22922 {
22923 if(game->get_counter(grab_next_argument())>=grab_next_argument())
22924 goto switched;
22925
22926 (void)grab_next_argument();
22927 return true;
22928 }
22929
22930 case MSGC_GOTOIFCTRPC:
22931 {
22932 int32_t counter = grab_next_argument();
22933 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
22934
22935 if(game->get_counter(counter)>=amount)
22936 goto switched;
22937
22938 (void)grab_next_argument();
22939 return true;
22940 }
22941
22942 case MSGC_GOTOIFTRICOUNT:
22943 {
22944 if(TriforceCount() >= (int32_t)(grab_next_argument()))
22945 goto switched;
22946
22947 (void)grab_next_argument();
22948 return true;
22949 }
22950
22951 case MSGC_GOTOIFTRI:
22952 {
22953 int32_t lev = (int32_t)(grab_next_argument());
22954
22955 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
22956 goto switched;
22957
22958 (void)grab_next_argument();
22959 return true;
22960 }
22961
22962 case MSGC_SETUPMENU:
22963 {
22964 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
22965 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
22966 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
22967 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
22968 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
22969 return true;
22970 }
22971
22972 case MSGC_MENUCHOICE:
22973 {
22974 int32_t pos = grab_next_argument();
22975 int32_t upos = grab_next_argument();
22976 int32_t dpos = grab_next_argument();
22977 int32_t lpos = grab_next_argument();
22978 int32_t rpos = grab_next_argument();
22979 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
22980 {
22981 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
22982 ssc_tile_hei = ssc_tile_hei_buf;
22983 ssc_tile_hei_buf = -1;
22984 cursor_y += thei + MsgStrings[msgstr].vspace;
22985 if(bottom_margin_clip()) break;
22986 cursor_x=msg_margins[left];
22987 }
22988
22989 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
22990 upos, dpos, lpos, rpos);
22991
22992 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
22993 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
22994 return true;
22995 }
22996
22997 case MSGC_RUNMENU:
22998 {
22999 msg_menu_data[MNU_CHOSEN] = 0;
23000 msg_menu_data[MNU_CAN_CONFIRM] = 0;
23001 if(menu_options.size() < 1)
23002 return true;
23003 do_run_menu = true;
23004 return true;
23005 }
23006
23007 case MSGC_GOTOMENUCHOICE:
23008 {
23009 int32_t choice = grab_next_argument();
23010 if(msg_menu_data[MNU_CHOSEN] == choice)
23011 goto switched;
23012 (void)grab_next_argument();
23013 return true;
23014 }
23015
23016 case MSGC_ENDSTRING:
23017 {
23018 do_end_str = true;
23019 return true;
23020 }
23021 case MSGC_WAIT_ADVANCE:
23022 {
23023 wait_advance = true;
23024 linkedmsgclk = 51;
23025 return true;
23026 }
23027 case MSGC_TRIGSECRETS:
23028 {
23029 bool perm = (bool)grab_next_argument();
23030 hidden_entrance(0, true, false, -8);
23031 if(perm)
23032 setmapflag(mSECRET);
23033 return true;
23034 }
23035 case MSGC_SETSCREENSTATE:
23036 {
23037 int32_t flag = int32_t(grab_next_argument());
23038 if(unsigned(flag)>=mMAXIND)
23039 {
23040 Z_error("SCC 133: Flag %d is invalid\n", flag);
23041 return true;
23042 }
23043 bool state = bool(grab_next_argument());
23044 if(state)
23045 setmapflag(1<<flag);
23046 else
23047 unsetmapflag(1<<flag,true);
23048 return true;
23049 }
23050 case MSGC_SETSCREENSTATER:
23051 {
23052 int32_t map = (int32_t)grab_next_argument();
23053 int32_t scrid = (int32_t)grab_next_argument();
23054 if(map < 1 || map > map_count)
23055 {
23056 Z_error("SCC 134: Map %d is invalid\n", map);
23057 return true;
23058 }
23059 if(unsigned(scrid)>=0x80)
23060 {
23061 Z_error("SCC 134: Screen %d is invalid\n", scrid);
23062 return true;
23063 }
23064
23065 int32_t flag = int32_t(grab_next_argument());
23066 if(unsigned(flag)>=mMAXIND)
23067 {
23068 Z_error("SCC 134: Flag %d is invalid\n", flag);
23069 return true;
23070 }
23071 bool state = bool(grab_next_argument());
23072 if(state)
23073 setmapflag(mapind(map,scrid),1<<flag);
23074 else
23075 unsetmapflag(mapind(map,scrid),1<<flag,true);
23076 return true;
23077 }
23078 switched:
23079 int32_t lev = (int32_t)(grab_next_argument());
23080 if(lev && get_bit(quest_rules, qr_SCC_GOTO_RESPECTS_CONTFLAG)
23081 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
23082 {
23083 msgstr=lev;
23084 msgpos=msgptr=0;
23085 msgfont=setmsgfont();
23086 }
23087 else donewmsg(lev);
23088 msgptr--; // To counteract it being incremented after this routine is called.
23089 putprices(false);
23090 return true;
23091 }
23092
23093 41703 return false;
23094 42445 }
23095
23096 // Wraps the message string... probably.
23097 41300 void wrapmsgstr(char *s3)
23098 {
23099 41300 int32_t j=0;
23100
23101
2/2
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 31621 times.
41300 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23102 {
23103
2/2
✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 7598 times.
9679 if(msgspace)
23104 {
23105 2081 char c = MsgStrings[msgstr].s[msgptr];
23106
4/6
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1786 times.
✗ Branch 5 not taken.
2081 if(c != ' ' && c >= 32 && c <= 126)
23107 {
23108
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9806 times.
✓ Branch 2 taken 8026 times.
✓ Branch 3 taken 1786 times.
9812 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
23109 {
23110
3/4
✓ Branch 0 taken 7734 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7734 times.
8026 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
23111 8026 }
23112
23113 1786 s3[j] = 0;
23114 1786 msgspace = false;
23115 1786 }
23116 else
23117 {
23118 295 s3[0] = c;
23119 295 s3[1] = 0;
23120 }
23121 2081 }
23122 else
23123 {
23124 7598 s3[0] = MsgStrings[msgstr].s[msgptr];
23125 7598 s3[1] = 0;
23126
23127
2/2
✓ Branch 0 taken 5948 times.
✓ Branch 1 taken 1650 times.
7598 if(s3[0] == ' ') msgspace=true;
23128 }
23129 9679 }
23130 else
23131 {
23132 31621 s3[0] = MsgStrings[msgstr].s[msgptr];
23133 31621 s3[1] = 0;
23134 }
23135 41300 }
23136
23137 // Returns true if the pointer is at a string's
23138 // null terminator or a trailing space
23139 131213 bool atend(char const* str)
23140 {
23141 131213 int32_t i=0;
23142
23143
2/2
✓ Branch 0 taken 1355858 times.
✓ Branch 1 taken 131213 times.
1487071 while(str[i]==' ')
23144 1355858 i++;
23145
23146 131213 return str[i]=='\0';
23147 }
23148
23149 5173306 void putmsg()
23150 {
23151 5173306 bool oldmargin = get_bit(quest_rules, qr_OLD_STRING_EDITOR_MARGINS)!=0;
23152
2/2
✓ Branch 0 taken 5047705 times.
✓ Branch 1 taken 125601 times.
5173306 if(!msgorig) msgorig=msgstr;
23153
23154
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5173306 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5173306 if(wait_advance && linkedmsgclk < 1)
23155 linkedmsgclk = 1;
23156
2/2
✓ Branch 0 taken 5146765 times.
✓ Branch 1 taken 26541 times.
5173306 if(linkedmsgclk>0)
23157 {
23158
2/2
✓ Branch 0 taken 6740 times.
✓ Branch 1 taken 19801 times.
26541 if(linkedmsgclk==1)
23159 {
23160
5/6
✓ Branch 0 taken 6740 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6428 times.
✓ Branch 3 taken 312 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 6344 times.
6740 if(do_end_str||cAbtn()||cBbtn())
23161 {
23162 396 do_end_str = false;
23163 396 linkedmsgclk = 0;
23164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 396 times.
396 if(wait_advance)
23165 {
23166 wait_advance = false;
23167 }
23168 else
23169 {
23170 396 msgstr=MsgStrings[msgstr].nextstring;
23171
3/4
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 229 times.
✓ Branch 2 taken 167 times.
✗ Branch 3 not taken.
396 if(!msgstr && enqueued_str)
23172 {
23173 msgstr = enqueued_str;
23174 enqueued_str = 0;
23175 }
23176
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 167 times.
396 if(!msgstr)
23177 {
23178 167 msgfont=zfont;
23179
23180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
167 if(tmpscr->room!=rGRUMBLE)
23181 167 blockpath=false;
23182
23183 167 dismissmsg();
23184 167 goto disappear;
23185 }
23186
23187 229 donewmsg(msgstr);
23188 229 putprices(false);
23189 }
23190 229 }
23191 6573 }
23192 else
23193 {
23194 19801 --linkedmsgclk;
23195 }
23196 26374 }
23197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5173139 times.
5173139 if(wait_advance) return; //Waiting for buttonpress
23198
23199
9/10
✓ Branch 0 taken 5173029 times.
✓ Branch 1 taken 110 times.
✓ Branch 2 taken 124758 times.
✓ Branch 3 taken 5048271 times.
✓ Branch 4 taken 83818 times.
✓ Branch 5 taken 40940 times.
✓ Branch 6 taken 37598 times.
✓ Branch 7 taken 46220 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 37598 times.
5173139 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
23200 {
23201
2/2
✓ Branch 0 taken 87160 times.
✓ Branch 1 taken 5048271 times.
5135431 if(!msgstr)
23202 5048271 msgorig=0;
23203
23204 5135431 msg_active = false;
23205 5135431 return;
23206 }
23207
23208 37708 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
23209
23210 char s3[145];
23211 int32_t tlength;
23212
23213 // Bypass the string with the B button!
23214
4/4
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 37392 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 37192 times.
37708 if(((cBbtn())&&(get_bit(quest_rules,qr_ALLOWMSGBYPASS))) || msgspeed==0)
23215 {
23216 //finish writing out the string
23217
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 26138 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 25741 times.
26257 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
23218 {
23219
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 8739 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
25741 if(msgspeed && !(cBbtn() && get_bit(quest_rules,qr_ALLOWMSGBYPASS)))
23220 goto breakout; // break out if message speed was changed to non-zero
23221
4/6
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25741 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 25505 times.
25741 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23222 {
23223
1/2
✓ Branch 0 taken 25505 times.
✗ Branch 1 not taken.
25505 if(bottom_margin_clip())
23224 break;
23225
23226 25505 wrapmsgstr(s3);
23227
23228
2/2
✓ Branch 0 taken 5723 times.
✓ Branch 1 taken 19782 times.
25505 if(MsgStrings[msgstr].s[msgptr]==' ')
23229 {
23230 5723 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23231
23232
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 157 times.
5923 if(cursor_x+tlength > (msg_w-msg_margins[right])
23233
5/6
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 5523 times.
✓ Branch 2 taken 200 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 200 times.
✓ Branch 5 taken 43 times.
5723 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23234 43 ? true : strcmp(s3," ")!=0))
23235 {
23236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
243 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23237 157 ssc_tile_hei = ssc_tile_hei_buf;
23238 157 ssc_tile_hei_buf = -1;
23239 157 cursor_y += thei + MsgStrings[msgstr].vspace;
23240
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(bottom_margin_clip()) break;
23241 157 cursor_x=msg_margins[left];
23242 157 }
23243
23244 5723 char buf[2] = {0};
23245 5723 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23246
23247 5723 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23248
23249 5723 cursor_x+=tlength;
23250 5723 }
23251 else
23252 {
23253 19782 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23254
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 314 times.
20264 if(cursor_x+tlength > (msg_w-msg_margins[right])
23255
5/6
✓ Branch 0 taken 525 times.
✓ Branch 1 taken 19257 times.
✓ Branch 2 taken 482 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 357 times.
✗ Branch 5 not taken.
19782 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23256 168 ? true : strcmp(s3," ")!=0))
23257 {
23258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 525 times.
525 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23259 525 ssc_tile_hei = ssc_tile_hei_buf;
23260 525 ssc_tile_hei_buf = -1;
23261 525 cursor_y += thei + MsgStrings[msgstr].vspace;
23262
1/2
✓ Branch 0 taken 525 times.
✗ Branch 1 not taken.
525 if(bottom_margin_clip()) break;
23263 525 cursor_x=msg_margins[left];
23264 525 }
23265
23266 19782 sfx(MsgStrings[msgstr].sfx);
23267
23268 19782 char buf[2] = {0};
23269 19782 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23270
23271 19782 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23272
23273 19782 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23274 19782 cursor_x += MsgStrings[msgstr].hspace;
23275 }
23276
23277 25505 msgpos++;
23278 25505 }
23279
1/2
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
25741 if(do_run_menu)
23280 {
23281 if(runMenuCursor())
23282 {
23283 do_run_menu = false;
23284 }
23285 else break;
23286 }
23287
1/2
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
25741 if(doing_name_insert)
23288 {
23289 if(*nameptr)
23290 {
23291 if(bottom_margin_clip())
23292 break;
23293
23294 char s3[9] = {0};
23295
23296 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23297 {
23298 strcpy(s3, nameptr);
23299 }
23300 else
23301 {
23302 s3[0] = *nameptr;
23303 s3[1] = 0;
23304 }
23305
23306 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23307
23308 if(cursor_x+tlength > (msg_w-msg_margins[right])
23309 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23310 ? true : strcmp(s3," ")!=0))
23311 {
23312 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23313 ssc_tile_hei = ssc_tile_hei_buf;
23314 ssc_tile_hei_buf = -1;
23315 cursor_y += thei + MsgStrings[msgstr].vspace;
23316 if(bottom_margin_clip()) break;
23317 cursor_x=msg_margins[left];
23318 }
23319
23320 sfx(MsgStrings[msgstr].sfx);
23321
23322 char buf[2] = {0};
23323 sprintf(buf,"%c",*nameptr);
23324
23325 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23326
23327 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23328 cursor_x += MsgStrings[msgstr].hspace;
23329 ++nameptr;
23330 continue; //don't advance the msgptr, as the next char in it was not processed!
23331 }
23332 else doing_name_insert = false;
23333 }
23334 25741 ++msgptr;
23335
1/2
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
25741 if(do_end_str)
23336 goto strendcheck;
23337
1/2
✓ Branch 0 taken 25741 times.
✗ Branch 1 not taken.
25741 if(wait_advance)
23338 return;
23339
2/2
✓ Branch 0 taken 25335 times.
✓ Branch 1 taken 406 times.
25741 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23340 {
23341
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 171 times.
406 if(MsgStrings[msgstr].nextstring)
23342 {
23343
1/2
✓ Branch 0 taken 171 times.
✗ Branch 1 not taken.
171 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23344 {
23345 msgstr=MsgStrings[msgstr].nextstring;
23346 msgpos=msgptr=0;
23347 msgfont=setmsgfont();
23348 }
23349 171 }
23350 406 }
23351 }
23352
23353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 406 times.
406 if (!do_run_menu)
23354 {
23355 406 msgclk = 72;
23356 406 msgpos = 10000;
23357 406 }
23358 406 }
23359 else
23360 37192 {
23361 breakout:
23362
23363
6/6
✓ Branch 0 taken 30852 times.
✓ Branch 1 taken 6340 times.
✓ Branch 2 taken 14296 times.
✓ Branch 3 taken 16556 times.
✓ Branch 4 taken 9773 times.
✓ Branch 5 taken 4523 times.
37192 if(((msgclk++)%(msgspeed+1)<msgspeed)&&((!cAbtn())||(!get_bit(quest_rules,qr_ALLOWFASTMSG))))
23364 21079 return;
23365 }
23366
23367 // Start writing the string
23368
2/2
✓ Branch 0 taken 16023 times.
✓ Branch 1 taken 496 times.
17015 if(msgptr == 0)
23369 {
23370
2/2
✓ Branch 0 taken 496 times.
✓ Branch 1 taken 889 times.
1385 while(MsgStrings[msgstr].s[msgptr]==' ')
23371 {
23372 889 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23373
23374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
890 if(cursor_x+tlength > (msg_w-msg_margins[right])
23375
4/6
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
889 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23376 ? 1 : strcmp(s3," ")!=0))
23377 {
23378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23379 1 ssc_tile_hei = ssc_tile_hei_buf;
23380 1 ssc_tile_hei_buf = -1;
23381 1 cursor_y += thei + MsgStrings[msgstr].vspace;
23382
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(bottom_margin_clip()) break;
23383 1 cursor_x=msg_margins[left];
23384 1 }
23385
23386 889 cursor_x+=tlength;
23387 889 ++msgptr;
23388 889 ++msgpos;
23389
23390 // The "Continue From Previous" feature
23391
1/2
✓ Branch 0 taken 889 times.
✗ Branch 1 not taken.
889 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23392 {
23393 if(MsgStrings[msgstr].nextstring)
23394 {
23395 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23396 {
23397 msgstr=MsgStrings[msgstr].nextstring;
23398 msgpos=msgptr=0;
23399 msgfont=setmsgfont();
23400 }
23401 }
23402 }
23403 }
23404 496 }
23405
23406 reparsesinglechar:
23407 // Continue printing the string!
23408
3/4
✓ Branch 0 taken 15889 times.
✓ Branch 1 taken 630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15889 times.
32408 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
23409 {
23410
4/6
✓ Branch 0 taken 15889 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15889 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 15795 times.
15889 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
23411 {
23412 15795 wrapmsgstr(s3);
23413
23414 15795 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23415
23416
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 169 times.
15984 if(cursor_x+tlength > (msg_w-msg_margins[right])
23417
6/6
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 15602 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 169 times.
✓ Branch 5 taken 4 times.
15795 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23418 20 ? true : strcmp(s3," ")!=0))
23419 {
23420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23421 189 ssc_tile_hei = ssc_tile_hei_buf;
23422 189 ssc_tile_hei_buf = -1;
23423 189 cursor_y += thei + MsgStrings[msgstr].vspace;
23424
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(bottom_margin_clip()) goto strendcheck;
23425 189 cursor_x=msg_margins[left];
23426 //if(space) s3[0]=0;
23427 189 }
23428
23429 15795 sfx(MsgStrings[msgstr].sfx);
23430
23431 15795 char buf[2] = {0};
23432 15795 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
23433
23434 15795 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23435
23436 15795 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
23437 15795 cursor_x += MsgStrings[msgstr].hspace;
23438 15795 msgpos++;
23439 15795 }
23440
1/2
✓ Branch 0 taken 15889 times.
✗ Branch 1 not taken.
15889 if(do_end_str)
23441 goto strendcheck;
23442
1/2
✓ Branch 0 taken 15889 times.
✗ Branch 1 not taken.
15889 if(wait_advance)
23443 {
23444 ++msgptr;
23445 return;
23446 }
23447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15889 times.
15889 else if(do_run_menu)
23448 {
23449 if(runMenuCursor())
23450 {
23451 do_run_menu = false;
23452 ++msgptr;
23453 goto reparsesinglechar;
23454 }
23455 }
23456
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15889 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15889 else if(doing_name_insert && *nameptr)
23457 {
23458 char s3[9] = {0};
23459
23460 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
23461 {
23462 strcpy(s3, nameptr);
23463 }
23464 else
23465 {
23466 s3[0] = *nameptr;
23467 s3[1] = 0;
23468 }
23469
23470 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
23471
23472 if(cursor_x+tlength > (msg_w-msg_margins[right])
23473 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23474 ? true : strcmp(s3," ")!=0))
23475 {
23476 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23477 ssc_tile_hei = ssc_tile_hei_buf;
23478 ssc_tile_hei_buf = -1;
23479 cursor_y += thei + MsgStrings[msgstr].vspace;
23480 if(bottom_margin_clip()) goto strendcheck;
23481 cursor_x=msg_margins[left];
23482 }
23483
23484 sfx(MsgStrings[msgstr].sfx);
23485
23486 char buf[2] = {0};
23487 sprintf(buf,"%c",*nameptr);
23488
23489 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
23490
23491 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
23492 cursor_x += MsgStrings[msgstr].hspace;
23493 ++nameptr;
23494 }
23495 else
23496 {
23497 15889 doing_name_insert = false;
23498 15889 msgptr++;
23499
23500
2/2
✓ Branch 0 taken 15480 times.
✓ Branch 1 taken 409 times.
15889 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23501 {
23502
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 59 times.
409 if(MsgStrings[msgstr].nextstring)
23503 {
23504
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23505 {
23506 msgstr=MsgStrings[msgstr].nextstring;
23507 msgpos=msgptr=0;
23508 msgfont=setmsgfont();
23509 }
23510 59 }
23511 409 }
23512
23513
2/2
✓ Branch 0 taken 2354 times.
✓ Branch 1 taken 813 times.
19056 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
23514
2/2
✓ Branch 0 taken 15861 times.
✓ Branch 1 taken 28 times.
15889 && (MsgStrings[msgstr].s[msgptr]==' ')
23515
2/2
✓ Branch 0 taken 3167 times.
✓ Branch 1 taken 12694 times.
15861 && (MsgStrings[msgstr].s[msgptr+1]==' '))
23516 {
23517
2/2
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 30327 times.
31140 while(MsgStrings[msgstr].s[msgptr]==' ')
23518 {
23519 30327 msgspace = true;
23520 30327 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
23521
23522
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1309 times.
31659 if(cursor_x+tlength > (msg_w-msg_margins[right])
23523
4/6
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 28995 times.
✓ Branch 2 taken 1332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1309 times.
✗ Branch 5 not taken.
30327 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
23524 23 ? true : strcmp(s3," ")!=0))
23525 {
23526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1332 times.
1332 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
23527 1332 ssc_tile_hei = ssc_tile_hei_buf;
23528 1332 ssc_tile_hei_buf = -1;
23529 1332 cursor_y += thei + MsgStrings[msgstr].vspace;
23530
1/2
✓ Branch 0 taken 1332 times.
✗ Branch 1 not taken.
1332 if(bottom_margin_clip()) break;
23531 1332 cursor_x=msg_margins[left];
23532 1332 }
23533
23534 30327 cursor_x+=tlength;
23535 30327 ++msgpos;
23536 30327 ++msgptr;
23537
23538
2/2
✓ Branch 0 taken 2213 times.
✓ Branch 1 taken 28114 times.
30327 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
23539 {
23540
2/2
✓ Branch 0 taken 24063 times.
✓ Branch 1 taken 4051 times.
28114 if(MsgStrings[msgstr].nextstring)
23541 {
23542
1/2
✓ Branch 0 taken 4051 times.
✗ Branch 1 not taken.
4051 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
23543 {
23544 msgstr=MsgStrings[msgstr].nextstring;
23545 msgpos=msgptr=0;
23546 msgfont=setmsgfont();
23547 }
23548 4051 }
23549 28114 }
23550 }
23551 813 }
23552 }
23553 15889 }
23554 strendcheck:
23555 // Done printing the string
23556
10/14
✓ Branch 0 taken 16519 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16519 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16519 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16113 times.
✓ Branch 7 taken 406 times.
✓ Branch 8 taken 15710 times.
✓ Branch 9 taken 403 times.
✓ Branch 10 taken 15710 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 15704 times.
✓ Branch 13 taken 815 times.
16519 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
23557 {
23558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
815 if(!do_end_str)
23559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 815 times.
815 while(parsemsgcode()); // Finish remaining control codes
23560
23561 // Go to next string, or make it disappear by going to string 0.
23562
5/6
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 418 times.
✓ Branch 3 taken 167 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 418 times.
815 if(MsgStrings[msgstr].nextstring!=0 || get_bit(quest_rules,qr_MSGDISAPPEAR) || enqueued_str)
23563 {
23564 397 linkedmsgclk=do_end_str?1:51;
23565 397 }
23566
23567
2/2
✓ Branch 0 taken 585 times.
✓ Branch 1 taken 230 times.
815 if(MsgStrings[msgstr].nextstring==0)
23568 {
23569
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 418 times.
585 if(!get_bit(quest_rules,qr_MSGDISAPPEAR))
23570 418 {
23571 disappear:
23572 585 msg_active = false;
23573 585 Hero.finishedmsg();
23574 585 }
23575
23576
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 12 times.
752 if(repaircharge)
23577 {
23578 // if (get_bit(quest_rules,qr_REPAIRFIX)) {
23579 // fixed_door=true;
23580 // }
23581 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
23582 12 repaircharge = 0;
23583 12 }
23584
23585
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 1 times.
752 if(adjustmagic)
23586 {
23587
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_bit(quest_rules,qr_OLD_HALF_MAGIC))
23588 {
23589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
23590 1 game->set_magicdrainrate(1);
23591 1 }
23592 else if(game->get_magicdrainrate() > 1)
23593 {
23594 game->set_magicdrainrate(game->get_magicdrainrate()/2);
23595 }
23596 1 adjustmagic = false;
23597 1 sfx(WAV_SCALE);
23598
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23599 1 }
23600
23601
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 1 times.
752 if(learnslash)
23602 {
23603 1 game->set_canslash(1);
23604 1 learnslash = false;
23605 1 sfx(WAV_SCALE);
23606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 setmapflag((currscr < 128 && get_bit(quest_rules, qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
23607 1 }
23608 752 }
23609 982 }
23610 5173196 }
23611
23612 6556 int32_t message_more_y()
23613 {
23614 //Is the flag ticked, do we really want a message more y larger than 160?
23615
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 6542 times.
✓ Branch 2 taken 6556 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6542 times.
✓ Branch 5 taken 14 times.
6556 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
23616 6556 msgy+=playing_field_offset;
23617 6556 return msgy;
23618 }
23619
23620 /*** Collision detection & handling ***/
23621
23622 5150995 void clear_script_one_frame_conditions()
23623 {
23624
2/2
✓ Branch 0 taken 16101087 times.
✓ Branch 1 taken 5150995 times.
21252082 for(int32_t j=0; j<guys.Count(); j++)
23625 {
23626 16101087 enemy *e = (enemy*)guys.spr(j);
23627
2/2
✓ Branch 0 taken 257617392 times.
✓ Branch 1 taken 16101087 times.
273718479 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
23628 16101087 }
23629 5150995 }
23630
23631 5150916 void check_collisions()
23632 {
23633 5150916 bool temp_hit = false;
23634
2/2
✓ Branch 0 taken 2324602 times.
✓ Branch 1 taken 5150916 times.
7475518 for(int32_t i=0; i<Lwpns.Count(); i++)
23635 {
23636 2324602 weapon *w = (weapon*)Lwpns.spr(i);
23637
23638
8/8
✓ Branch 0 taken 2013812 times.
✓ Branch 1 taken 310790 times.
✓ Branch 2 taken 1695816 times.
✓ Branch 3 taken 317996 times.
✓ Branch 4 taken 1693038 times.
✓ Branch 5 taken 2778 times.
✓ Branch 6 taken 10727 times.
✓ Branch 7 taken 1682311 times.
2324602 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
23639 {
23640
2/2
✓ Branch 0 taken 1673455 times.
✓ Branch 1 taken 5971119 times.
7644574 for(int32_t j=0; j<guys.Count(); j++)
23641 {
23642 5971119 enemy *e = (enemy*)guys.spr(j);
23643
2/2
✓ Branch 0 taken 54375 times.
✓ Branch 1 taken 5916744 times.
5971119 if ( !temp_hit ) e->hitby[HIT_BY_LWEAPON] = 0;
23644
23645
2/2
✓ Branch 0 taken 5861423 times.
✓ Branch 1 taken 109696 times.
5971119 if(e->hit(w)) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
23646 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
23647 {
23648 // !(e->stunclk)
23649 109696 int32_t h = e->takehit(w);
23650
2/2
✓ Branch 0 taken 91839 times.
✓ Branch 1 taken 17857 times.
109696 if (h == -1)
23651 {
23652 17857 e->hitby[HIT_BY_LWEAPON] = i+1; temp_hit = true;
23653 17857 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
23654 //e->hitby[HIT_BY_LWEAPON_FAMILY] = itemsbuf[w->parentid].family; //that would be the itemclass, not the weapon type!
23655 17857 e->hitby[HIT_BY_LWEAPON_FAMILY] = w->id;
23656 //al_trace("npc->HitBy[] Parent Item is: %d /n", w->parentitem);
23657 //al_trace("npc->HitBy[] Parent ID is: %d /n", w->parentid);
23658 17857 e->hitby[HIT_BY_LWEAPON_LITERAL_ID] = w->parentitem;
23659
23660 17857 }
23661 //we may need to handle this in special cases. -Z
23662
23663 //if h == stun or ignore
23664
23665 //if e->stun > DEFAULT_STUN -1 || !e->stun
23666 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
23667 ///! how about: if w->dead != bounce !
23668
23669 // NOT FOR PUBLIC RELEASE
23670 /*if(h==3) //Mirror shield
23671 {
23672 if (w->id==ewFireball || w->id==wRefFireball)
23673 {
23674 w->id=wRefFireball;
23675 switch(e->dir)
23676 {
23677 case up: e->angle += (PI - e->angle) * 2.0; break;
23678 case down: e->angle = -e->angle; break;
23679 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
23680 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
23681 // TODO: the following. -L.
23682 case l_up: break;
23683 case r_up: break;
23684 case l_down: break;
23685 case r_down: break;
23686 }
23687 }
23688 else
23689 {
23690 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
23691 w->dir ^= 1;
23692 if(w->dir&2)
23693 w->flip ^= 1;
23694 else
23695 w->flip ^= 2;
23696 }
23697 w->ignoreHero=false;
23698 }
23699 else*/
23700
2/2
✓ Branch 0 taken 86025 times.
✓ Branch 1 taken 23671 times.
109696 if(h)
23701 {
23702
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23671 if(e->switch_hooked && w->family_class == itype_switchhook)
23703 w->onhit(false, e, -1);
23704 23671 else w->onhit(false, e, h);
23705 23671 }
23706
23707
2/2
✓ Branch 0 taken 107512 times.
✓ Branch 1 taken 2184 times.
109696 if(h==2)
23708 {
23709 2184 break;
23710 }
23711 107512 }
23712
23713
2/2
✓ Branch 0 taken 5962263 times.
✓ Branch 1 taken 6672 times.
5968935 if(w->Dead())
23714 {
23715 6672 break;
23716 }
23717 5962263 }
23718
23719 // Item flags added in 2.55:
23720 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
23721 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
23722 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
23723 // -V
23724
6/6
✓ Branch 0 taken 1431412 times.
✓ Branch 1 taken 250899 times.
✓ Branch 2 taken 1429611 times.
✓ Branch 3 taken 1801 times.
✓ Branch 4 taken 9758 times.
✓ Branch 5 taken 1419853 times.
1682311 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
23725 {
23726 262458 int32_t itype, pitem = w->parentitem;
23727
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250899 times.
✓ Branch 2 taken 9758 times.
✓ Branch 3 taken 1801 times.
262458 switch(w->id)
23728 {
23729 250899 case wBrang: itype = itype_brang; break;
23730 9758 case wArrow: itype = itype_arrow; break;
23731 case wHookshot:
23732 1801 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
23733 1801 break;
23734 }
23735
2/2
✓ Branch 0 taken 261293 times.
✓ Branch 1 taken 1165 times.
262458 if(pitem < 0) pitem = current_item_id(itype);
23736
5/6
✓ Branch 0 taken 1801 times.
✓ Branch 1 taken 260657 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 1701 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
262458 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
23737 { //Swap with item
23738 for(int32_t j=0; j<items.Count(); j++)
23739 {
23740 if(items.spr(j)->hit(w))
23741 {
23742 item *theItem = ((item*)items.spr(j));
23743 bool priced = theItem->PriceIndex >-1;
23744 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23745 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23746 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23747 {
23748 if(!Hero.switchhookclk)
23749 {
23750 hooked_combopos = -1;
23751 hooked_layerbits = 0;
23752 switching_object = theItem;
23753 theItem->switch_hooked = true;
23754 w->misc = 2;
23755 w->step = 0;
23756 theItem->clk2=256;
23757 Hero.doSwitchHook(game->get_switchhookstyle());
23758 if(QMisc.miscsfx[sfxSWITCHED])
23759 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
23760 }
23761 }
23762 }
23763 }
23764 }
23765
6/6
✓ Branch 0 taken 9758 times.
✓ Branch 1 taken 252700 times.
✓ Branch 2 taken 245304 times.
✓ Branch 3 taken 235546 times.
✓ Branch 4 taken 252700 times.
✓ Branch 5 taken 235546 times.
262458 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
23766 {
23767
2/2
✓ Branch 0 taken 58777 times.
✓ Branch 1 taken 245304 times.
304081 for(int32_t j=0; j<items.Count(); j++)
23768 {
23769
2/2
✓ Branch 0 taken 55361 times.
✓ Branch 1 taken 3416 times.
58777 if(items.spr(j)->hit(w))
23770 {
23771 3416 item *theItem = ((item*)items.spr(j));
23772 3416 bool priced = theItem->PriceIndex >-1;
23773
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 3402 times.
3416 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23774
5/8
✓ Branch 0 taken 3416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2798 times.
✓ Branch 5 taken 618 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1539 times.
4955 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23775
4/6
✓ Branch 0 taken 2157 times.
✓ Branch 1 taken 1539 times.
✓ Branch 2 taken 2157 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2157 times.
3416 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
23776 {
23777
1/2
✓ Branch 0 taken 1259 times.
✗ Branch 1 not taken.
4337 if(itemsbuf[theItem->id].collect_script)
23778 {
23779 ZScriptVersion::RunScript(SCRIPT_ITEM, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
23780 }
23781
23782 1259 Hero.checkitems(j);
23783 1259 }
23784 3416 }
23785 58777 }
23786 245304 }
23787
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 15966 times.
488246 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
23788 {
23789
2/2
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 15966 times.
19300 for(int32_t j=0; j<items.Count(); j++)
23790 {
23791
2/2
✓ Branch 0 taken 2399 times.
✓ Branch 1 taken 935 times.
3334 if(items.spr(j)->hit(w))
23792 {
23793 935 item *theItem = ((item*)items.spr(j));
23794 935 bool priced = theItem->PriceIndex >-1;
23795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
23796
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
23797
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
23798 {
23799 559 int32_t pickup = theItem->pickup;
23800 559 int32_t id2 = theItem->id;
23801 559 int32_t pstr = theItem->pstring;
23802 559 int32_t pstr_flags = theItem->pickup_string_flags;
23803
23804 559 std::vector<int32_t> &ev = FFCore.eventData;
23805 559 ev.clear();
23806 559 ev.push_back(id2*10000);
23807 559 ev.push_back(pickup*10000);
23808 559 ev.push_back(pstr*10000);
23809 559 ev.push_back(pstr_flags*10000);
23810 559 ev.push_back(0);
23811 559 ev.push_back(theItem->getUID());
23812 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
23813 559 ev.push_back(w->getUID());
23814
23815 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
23816 559 bool nullify = ev[4] != 0;
23817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
23818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
23819 {
23820 559 w->onhit(false);
23821 559 }
23822
23823
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
23824 {
23825 37 w->dead=1;
23826 37 theItem->clk2=256;
23827 37 w->dragging=j;
23828 37 theItem->is_dragged = true;
23829 37 }
23830 559 }
23831 935 }
23832 3334 }
23833 15966 }
23834 262458 }
23835 1682311 }
23836 2324602 }
23837 5150916 }
23838
23839 5150995 void dragging_item()
23840 {
23841
2/2
✓ Branch 0 taken 2363020 times.
✓ Branch 1 taken 5150995 times.
7514015 for(int32_t i=0; i<Lwpns.Count(); i++)
23842 {
23843 2363020 weapon *w = (weapon*)Lwpns.spr(i);
23844
23845
4/4
✓ Branch 0 taken 2106846 times.
✓ Branch 1 taken 256174 times.
✓ Branch 2 taken 2346713 times.
✓ Branch 3 taken 16307 times.
2363020 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
23846 {
23847
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16307 if(w->dragging>=0 && w->dragging<items.Count())
23848 {
23849 551 item* dragItem = (item*)items.spr(w->dragging);
23850 551 dragItem->x=w->x;
23851 551 dragItem->y=w->y;
23852
23853 // Drag the Fairy enemy as well as the Fairy item
23854 551 int32_t id = dragItem->id;
23855
23856
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
23857 {
23858 movefairynew2(w->x,w->y,*dragItem);
23859 }
23860 551 }
23861 16307 }
23862 2363020 }
23863 5150995 }
23864
23865 20 int32_t more_carried_items()
23866 {
23867 20 int32_t hasmorecarries = 0;
23868
23869
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 20 times.
42 for(int32_t i=0; i<items.Count(); i++)
23870 {
23871
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 20 times.
22 if(((item*)items.spr(i))->pickup & ipENEMY)
23872 {
23873 20 hasmorecarries++;
23874 20 }
23875 22 }
23876
23877 20 return hasmorecarries;
23878 }
23879
23880 // messy code to do the enemy-carrying-the-item thing
23881 5150995 void roaming_item()
23882 {
23883
4/4
✓ Branch 0 taken 9588 times.
✓ Branch 1 taken 5141407 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 9566 times.
5150995 if(!(hasitem&(4|2)) || !loaded_enemies)
23884 5141429 return;
23885
23886 // All enemies already dead upon entering a room?
23887
1/2
✓ Branch 0 taken 9566 times.
✗ Branch 1 not taken.
9566 if(guys.Count()==0)
23888 {
23889 return;
23890 }
23891
23892 // Lost track of the carrier?
23893
4/6
✓ Branch 0 taken 9566 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9566 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9561 times.
✓ Branch 5 taken 5 times.
9566 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
23894 9566 !((enemy*)guys.spr(guycarryingitem))->itemguy)
23895 {
23896 5 guycarryingitem=-1;
23897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 for(int32_t j=0; j<guys.Count(); j++)
23898 {
23899
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5 times.
19 if(((enemy*)guys.spr(j))->itemguy)
23900 {
23901 5 guycarryingitem=j;
23902 5 break;
23903 }
23904 14 }
23905 5 }
23906
23907
2/2
✓ Branch 0 taken 9545 times.
✓ Branch 1 taken 21 times.
9566 if(hasitem&4)
23908 {
23909 21 guycarryingitem = -1;
23910
23911
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 21 times.
189 for(int32_t i=0; i<guys.Count(); i++)
23912 {
23913
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 21 times.
168 if(((enemy*)guys.spr(i))->itemguy)
23914 {
23915 21 guycarryingitem = i;
23916 21 }
23917 168 }
23918
23919
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(guycarryingitem == -1) //This happens when "default enemies" such as
23920 {
23921 return; //eSHOOTFBALL are alive but enemies from the list
23922 } //are not. Defer to HeroClass::checkspecial().
23923
23924 21 int32_t Item=tmpscr->item;
23925
23926 21 hasitem &= ~4;
23927
23928
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
23929 {
23930 39 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
23931
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 18 times.
21 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
23932 );
23933 21 hasitem |= 2;
23934 21 }
23935 else
23936 {
23937 return;
23938 }
23939 21 }
23940
23941
2/2
✓ Branch 0 taken 10080 times.
✓ Branch 1 taken 9566 times.
19646 for(int32_t i=0; i<items.Count(); i++)
23942 {
23943
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 9566 times.
10080 if(((item*)items.spr(i))->pickup&ipENEMY)
23944 {
23945
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 7221 times.
9566 if(get_bit(quest_rules,qr_HIDECARRIEDITEMS))
23946 {
23947 7221 items.spr(i)->x = -128; // Awfully inelegant, innit?
23948 7221 items.spr(i)->y = -128;
23949 7221 }
23950
2/4
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2345 times.
2345 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
23951 {
23952
1/2
✓ Branch 0 taken 2345 times.
✗ Branch 1 not taken.
2345 if (!get_bit(quest_rules, qr_BROKEN_ITEM_CARRYING))
23953 {
23954 if (get_bit(quest_rules, qr_ENEMY_DROPS_USE_HITOFFSETS))
23955 {
23956 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hxsz/2)-8;
23957 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hysz/2)-10;
23958 }
23959 else
23960 {
23961 if(guys.spr(guycarryingitem)->extend >= 3)
23962 {
23963 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
23964 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
23965 }
23966 else
23967 {
23968 items.spr(i)->x = guys.spr(guycarryingitem)->x;
23969 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
23970 }
23971 }
23972 items.spr(i)->z = guys.spr(guycarryingitem)->z;
23973 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
23974 }
23975 else
23976 {
23977 2345 items.spr(i)->x = guys.spr(guycarryingitem)->x;
23978 2345 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
23979 2345 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
23980 }
23981 2345 }
23982 9566 }
23983 10080 }
23984 5150995 }
23985
23986 bool enemy::IsBigAnim()
23987 {
23988 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
23989 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
23990 || anim == a4FRM8DIRB);
23991 }
23992
23993 const char *old_guy_string[OLDMAXGUYS] =
23994 {
23995 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
23996 // 020
23997 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
23998 // 025
23999 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
24000 // 030
24001 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
24002 // 035
24003 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
24004 // 040
24005 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
24006 // 045
24007 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
24008 // 050
24009 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
24010 // 055
24011 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
24012 // 060
24013 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
24014 // 065
24015 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
24016 // 070
24017 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
24018 // 075
24019 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
24020 // 080
24021 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
24022 // 085
24023 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
24024 // 090
24025 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
24026 // 095
24027 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
24028 // 100
24029 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
24030 // 105
24031 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
24032 // 110
24033 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
24034 // 115
24035 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
24036 // 120
24037 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
24038 // 125
24039 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
24040 // 130
24041 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
24042 // 135
24043 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
24044 // 140
24045 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
24046 // 145
24047 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
24048 // 150
24049 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
24050 // 155
24051 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
24052 // 160
24053 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
24054 // 165
24055 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
24056 // 170
24057 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
24058 // 175
24059 "Grappler Bug (HP) ", "Grappler Bug (MP) "
24060 };
24061
24062 /*** end of guys.cc ***/
24063
24064